* [PATCH] man/man3/pthread_attr_init.3: Replace errc
@ 2025-08-20 1:27 dave
2025-08-20 8:12 ` Alejandro Colomar
0 siblings, 1 reply; 4+ messages in thread
From: dave @ 2025-08-20 1:27 UTC (permalink / raw)
To: alx; +Cc: linux-man, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <dave@treblig.org>
The pthread_attr_init.3 example uses 'errc' to exit on an error
printing the error code. However, 'errc' is a BSDism that Linux
doesn't (and has never?) have.
Replace it by 'errx' with a strerror() call.
Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
---
man/man3/pthread_attr_init.3 | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/man/man3/pthread_attr_init.3 b/man/man3/pthread_attr_init.3
index e9058b8fe..9d0783e54 100644
--- a/man/man3/pthread_attr_init.3
+++ b/man/man3/pthread_attr_init.3
@@ -153,6 +153,7 @@ .SS Program source
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
\&
static void
@@ -165,7 +166,7 @@ .SS Program source
\&
s = pthread_attr_getdetachstate(attr, &i);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_getdetachstate");
+ errx(EXIT_FAILURE, "pthread_attr_getdetachstate: %s", strerror(s));
printf("%sDetach state = %s\[rs]n", prefix,
(i == PTHREAD_CREATE_DETACHED) ? "PTHREAD_CREATE_DETACHED" :
(i == PTHREAD_CREATE_JOINABLE) ? "PTHREAD_CREATE_JOINABLE" :
@@ -173,7 +174,7 @@ .SS Program source
\&
s = pthread_attr_getscope(attr, &i);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_getscope");
+ errx(EXIT_FAILURE, "pthread_attr_getscope: %s", strerror(s));
printf("%sScope = %s\[rs]n", prefix,
(i == PTHREAD_SCOPE_SYSTEM) ? "PTHREAD_SCOPE_SYSTEM" :
(i == PTHREAD_SCOPE_PROCESS) ? "PTHREAD_SCOPE_PROCESS" :
@@ -181,7 +182,7 @@ .SS Program source
\&
s = pthread_attr_getinheritsched(attr, &i);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_getinheritsched");
+ errx(EXIT_FAILURE, "pthread_attr_getinheritsched: %s", strerror(s));
printf("%sInherit scheduler = %s\[rs]n", prefix,
(i == PTHREAD_INHERIT_SCHED) ? "PTHREAD_INHERIT_SCHED" :
(i == PTHREAD_EXPLICIT_SCHED) ? "PTHREAD_EXPLICIT_SCHED" :
@@ -189,7 +190,7 @@ .SS Program source
\&
s = pthread_attr_getschedpolicy(attr, &i);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_getschedpolicy");
+ errx(EXIT_FAILURE, "pthread_attr_getschedpolicy: %s", strerror(s));
printf("%sScheduling policy = %s\[rs]n", prefix,
(i == SCHED_OTHER) ? "SCHED_OTHER" :
(i == SCHED_FIFO) ? "SCHED_FIFO" :
@@ -198,17 +199,17 @@ .SS Program source
\&
s = pthread_attr_getschedparam(attr, &sp);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_getschedparam");
+ errx(EXIT_FAILURE, "pthread_attr_getschedparam: %s", strerror(s));
printf("%sScheduling priority = %d\[rs]n", prefix, sp.sched_priority);
\&
s = pthread_attr_getguardsize(attr, &v);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_getguardsize");
+ errx(EXIT_FAILURE, "pthread_attr_getguardsize: %s", strerror(s));
printf("%sGuard size = %zu bytes\[rs]n", prefix, v);
\&
s = pthread_attr_getstack(attr, &stkaddr, &v);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_getstack");
+ errx(EXIT_FAILURE, "pthread_attr_getstack: %s", strerror(s));
printf("%sStack address = %p\[rs]n", prefix, stkaddr);
printf("%sStack size = %#zx bytes\[rs]n", prefix, v);
}
@@ -225,7 +226,7 @@ .SS Program source
\&
s = pthread_getattr_np(pthread_self(), &gattr);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_getattr_np");
+ errx(EXIT_FAILURE, "pthread_getattr_np: %s", strerror(s));
\&
printf("Thread attributes:\[rs]n");
display_pthread_attr(&gattr, "\[rs]t");
@@ -255,37 +256,37 @@ .SS Program source
\&
s = pthread_attr_init(&attr);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_init");
+ errx(EXIT_FAILURE, "pthread_attr_init: %s", strerror(s));
\&
s = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_setdetachstate");
+ errx(EXIT_FAILURE, "pthread_attr_setdetachstate: %s", strerror(s));
\&
s = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_setinheritsched");
+ errx(EXIT_FAILURE, "pthread_attr_setinheritsched: %s", strerror(s));
\&
stack_size = strtoul(argv[1], NULL, 0);
\&
s = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stack_size);
if (s != 0)
- errc(EXIT_FAILURE, s, "posix_memalign");
+ errx(EXIT_FAILURE, "posix_memalign: %s", strerror(s));
\&
printf("posix_memalign() allocated at %p\[rs]n", sp);
\&
s = pthread_attr_setstack(&attr, sp, stack_size);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_setstack");
+ errx(EXIT_FAILURE, "pthread_attr_setstack: %s", strerror(s));
}
\&
s = pthread_create(&thr, attrp, &thread_start, NULL);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_create");
+ errx(EXIT_FAILURE, "pthread_create: %s", strerror(s));
\&
if (attrp != NULL) {
s = pthread_attr_destroy(attrp);
if (s != 0)
- errc(EXIT_FAILURE, s, "pthread_attr_destroy");
+ errx(EXIT_FAILURE, "pthread_attr_destroy: %s", strerror(s));
}
\&
pause(); /* Terminates when other thread calls exit() */
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] man/man3/pthread_attr_init.3: Replace errc
2025-08-20 1:27 [PATCH] man/man3/pthread_attr_init.3: Replace errc dave
@ 2025-08-20 8:12 ` Alejandro Colomar
2025-08-20 14:10 ` Dr. David Alan Gilbert
0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar @ 2025-08-20 8:12 UTC (permalink / raw)
To: dave; +Cc: linux-man
[-- Attachment #1: Type: text/plain, Size: 6374 bytes --]
Hi Dave,
On Wed, Aug 20, 2025 at 02:27:25AM +0100, dave@treblig.org wrote:
> From: "Dr. David Alan Gilbert" <dave@treblig.org>
>
> The pthread_attr_init.3 example uses 'errc' to exit on an error
> printing the error code. However, 'errc' is a BSDism that Linux
> doesn't (and has never?) have.
Libbsd provides a compatbility layer to provide errc(3bsd) on Linux (and
many POSIX systems). libbsd is available in many distros (in Debian,
you should install libbsd-dev). BTW, it would be nice if glibc decided
to pick this API eventually.
Have a lovely day!
Alex
> Replace it by 'errx' with a strerror() call.
>
> Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
> ---
> man/man3/pthread_attr_init.3 | 31 ++++++++++++++++---------------
> 1 file changed, 16 insertions(+), 15 deletions(-)
>
> diff --git a/man/man3/pthread_attr_init.3 b/man/man3/pthread_attr_init.3
> index e9058b8fe..9d0783e54 100644
> --- a/man/man3/pthread_attr_init.3
> +++ b/man/man3/pthread_attr_init.3
> @@ -153,6 +153,7 @@ .SS Program source
> #include <pthread.h>
> #include <stdio.h>
> #include <stdlib.h>
> +#include <string.h>
> #include <unistd.h>
> \&
> static void
> @@ -165,7 +166,7 @@ .SS Program source
> \&
> s = pthread_attr_getdetachstate(attr, &i);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_getdetachstate");
> + errx(EXIT_FAILURE, "pthread_attr_getdetachstate: %s", strerror(s));
> printf("%sDetach state = %s\[rs]n", prefix,
> (i == PTHREAD_CREATE_DETACHED) ? "PTHREAD_CREATE_DETACHED" :
> (i == PTHREAD_CREATE_JOINABLE) ? "PTHREAD_CREATE_JOINABLE" :
> @@ -173,7 +174,7 @@ .SS Program source
> \&
> s = pthread_attr_getscope(attr, &i);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_getscope");
> + errx(EXIT_FAILURE, "pthread_attr_getscope: %s", strerror(s));
> printf("%sScope = %s\[rs]n", prefix,
> (i == PTHREAD_SCOPE_SYSTEM) ? "PTHREAD_SCOPE_SYSTEM" :
> (i == PTHREAD_SCOPE_PROCESS) ? "PTHREAD_SCOPE_PROCESS" :
> @@ -181,7 +182,7 @@ .SS Program source
> \&
> s = pthread_attr_getinheritsched(attr, &i);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_getinheritsched");
> + errx(EXIT_FAILURE, "pthread_attr_getinheritsched: %s", strerror(s));
> printf("%sInherit scheduler = %s\[rs]n", prefix,
> (i == PTHREAD_INHERIT_SCHED) ? "PTHREAD_INHERIT_SCHED" :
> (i == PTHREAD_EXPLICIT_SCHED) ? "PTHREAD_EXPLICIT_SCHED" :
> @@ -189,7 +190,7 @@ .SS Program source
> \&
> s = pthread_attr_getschedpolicy(attr, &i);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_getschedpolicy");
> + errx(EXIT_FAILURE, "pthread_attr_getschedpolicy: %s", strerror(s));
> printf("%sScheduling policy = %s\[rs]n", prefix,
> (i == SCHED_OTHER) ? "SCHED_OTHER" :
> (i == SCHED_FIFO) ? "SCHED_FIFO" :
> @@ -198,17 +199,17 @@ .SS Program source
> \&
> s = pthread_attr_getschedparam(attr, &sp);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_getschedparam");
> + errx(EXIT_FAILURE, "pthread_attr_getschedparam: %s", strerror(s));
> printf("%sScheduling priority = %d\[rs]n", prefix, sp.sched_priority);
> \&
> s = pthread_attr_getguardsize(attr, &v);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_getguardsize");
> + errx(EXIT_FAILURE, "pthread_attr_getguardsize: %s", strerror(s));
> printf("%sGuard size = %zu bytes\[rs]n", prefix, v);
> \&
> s = pthread_attr_getstack(attr, &stkaddr, &v);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_getstack");
> + errx(EXIT_FAILURE, "pthread_attr_getstack: %s", strerror(s));
> printf("%sStack address = %p\[rs]n", prefix, stkaddr);
> printf("%sStack size = %#zx bytes\[rs]n", prefix, v);
> }
> @@ -225,7 +226,7 @@ .SS Program source
> \&
> s = pthread_getattr_np(pthread_self(), &gattr);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_getattr_np");
> + errx(EXIT_FAILURE, "pthread_getattr_np: %s", strerror(s));
> \&
> printf("Thread attributes:\[rs]n");
> display_pthread_attr(&gattr, "\[rs]t");
> @@ -255,37 +256,37 @@ .SS Program source
> \&
> s = pthread_attr_init(&attr);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_init");
> + errx(EXIT_FAILURE, "pthread_attr_init: %s", strerror(s));
> \&
> s = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_setdetachstate");
> + errx(EXIT_FAILURE, "pthread_attr_setdetachstate: %s", strerror(s));
> \&
> s = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_setinheritsched");
> + errx(EXIT_FAILURE, "pthread_attr_setinheritsched: %s", strerror(s));
> \&
> stack_size = strtoul(argv[1], NULL, 0);
> \&
> s = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stack_size);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "posix_memalign");
> + errx(EXIT_FAILURE, "posix_memalign: %s", strerror(s));
> \&
> printf("posix_memalign() allocated at %p\[rs]n", sp);
> \&
> s = pthread_attr_setstack(&attr, sp, stack_size);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_setstack");
> + errx(EXIT_FAILURE, "pthread_attr_setstack: %s", strerror(s));
> }
> \&
> s = pthread_create(&thr, attrp, &thread_start, NULL);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_create");
> + errx(EXIT_FAILURE, "pthread_create: %s", strerror(s));
> \&
> if (attrp != NULL) {
> s = pthread_attr_destroy(attrp);
> if (s != 0)
> - errc(EXIT_FAILURE, s, "pthread_attr_destroy");
> + errx(EXIT_FAILURE, "pthread_attr_destroy: %s", strerror(s));
> }
> \&
> pause(); /* Terminates when other thread calls exit() */
> --
> 2.50.1
>
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] man/man3/pthread_attr_init.3: Replace errc
2025-08-20 8:12 ` Alejandro Colomar
@ 2025-08-20 14:10 ` Dr. David Alan Gilbert
2025-08-20 15:52 ` Alejandro Colomar
0 siblings, 1 reply; 4+ messages in thread
From: Dr. David Alan Gilbert @ 2025-08-20 14:10 UTC (permalink / raw)
To: Alejandro Colomar; +Cc: linux-man
* Alejandro Colomar (alx@kernel.org) wrote:
> Hi Dave,
Hi Alex,
> On Wed, Aug 20, 2025 at 02:27:25AM +0100, dave@treblig.org wrote:
> > From: "Dr. David Alan Gilbert" <dave@treblig.org>
> >
> > The pthread_attr_init.3 example uses 'errc' to exit on an error
> > printing the error code. However, 'errc' is a BSDism that Linux
> > doesn't (and has never?) have.
> Libbsd provides a compatbility layer to provide errc(3bsd) on Linux (and
> many POSIX systems). libbsd is available in many distros (in Debian,
> you should install libbsd-dev). BTW, it would be nice if glibc decided
> to pick this API eventually.
To use that we'd still need to change to:
#include <bsd/err.h>
and tell people to link with -lbsd
TBH using BSD only things in a Linux manpage with a _GNU_SOURCE define
seems odd. The err()/errc()/errx() family of calls seems to be pretty
obscure, most [linux] people I checked with had never used them.
But at least err/errx are in normal glibc.
Dave
>
> Have a lovely day!
> Alex
>
> > Replace it by 'errx' with a strerror() call.
> >
> > Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
> > ---
> > man/man3/pthread_attr_init.3 | 31 ++++++++++++++++---------------
> > 1 file changed, 16 insertions(+), 15 deletions(-)
> >
> > diff --git a/man/man3/pthread_attr_init.3 b/man/man3/pthread_attr_init.3
> > index e9058b8fe..9d0783e54 100644
> > --- a/man/man3/pthread_attr_init.3
> > +++ b/man/man3/pthread_attr_init.3
> > @@ -153,6 +153,7 @@ .SS Program source
> > #include <pthread.h>
> > #include <stdio.h>
> > #include <stdlib.h>
> > +#include <string.h>
> > #include <unistd.h>
> > \&
> > static void
> > @@ -165,7 +166,7 @@ .SS Program source
> > \&
> > s = pthread_attr_getdetachstate(attr, &i);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_getdetachstate");
> > + errx(EXIT_FAILURE, "pthread_attr_getdetachstate: %s", strerror(s));
> > printf("%sDetach state = %s\[rs]n", prefix,
> > (i == PTHREAD_CREATE_DETACHED) ? "PTHREAD_CREATE_DETACHED" :
> > (i == PTHREAD_CREATE_JOINABLE) ? "PTHREAD_CREATE_JOINABLE" :
> > @@ -173,7 +174,7 @@ .SS Program source
> > \&
> > s = pthread_attr_getscope(attr, &i);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_getscope");
> > + errx(EXIT_FAILURE, "pthread_attr_getscope: %s", strerror(s));
> > printf("%sScope = %s\[rs]n", prefix,
> > (i == PTHREAD_SCOPE_SYSTEM) ? "PTHREAD_SCOPE_SYSTEM" :
> > (i == PTHREAD_SCOPE_PROCESS) ? "PTHREAD_SCOPE_PROCESS" :
> > @@ -181,7 +182,7 @@ .SS Program source
> > \&
> > s = pthread_attr_getinheritsched(attr, &i);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_getinheritsched");
> > + errx(EXIT_FAILURE, "pthread_attr_getinheritsched: %s", strerror(s));
> > printf("%sInherit scheduler = %s\[rs]n", prefix,
> > (i == PTHREAD_INHERIT_SCHED) ? "PTHREAD_INHERIT_SCHED" :
> > (i == PTHREAD_EXPLICIT_SCHED) ? "PTHREAD_EXPLICIT_SCHED" :
> > @@ -189,7 +190,7 @@ .SS Program source
> > \&
> > s = pthread_attr_getschedpolicy(attr, &i);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_getschedpolicy");
> > + errx(EXIT_FAILURE, "pthread_attr_getschedpolicy: %s", strerror(s));
> > printf("%sScheduling policy = %s\[rs]n", prefix,
> > (i == SCHED_OTHER) ? "SCHED_OTHER" :
> > (i == SCHED_FIFO) ? "SCHED_FIFO" :
> > @@ -198,17 +199,17 @@ .SS Program source
> > \&
> > s = pthread_attr_getschedparam(attr, &sp);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_getschedparam");
> > + errx(EXIT_FAILURE, "pthread_attr_getschedparam: %s", strerror(s));
> > printf("%sScheduling priority = %d\[rs]n", prefix, sp.sched_priority);
> > \&
> > s = pthread_attr_getguardsize(attr, &v);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_getguardsize");
> > + errx(EXIT_FAILURE, "pthread_attr_getguardsize: %s", strerror(s));
> > printf("%sGuard size = %zu bytes\[rs]n", prefix, v);
> > \&
> > s = pthread_attr_getstack(attr, &stkaddr, &v);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_getstack");
> > + errx(EXIT_FAILURE, "pthread_attr_getstack: %s", strerror(s));
> > printf("%sStack address = %p\[rs]n", prefix, stkaddr);
> > printf("%sStack size = %#zx bytes\[rs]n", prefix, v);
> > }
> > @@ -225,7 +226,7 @@ .SS Program source
> > \&
> > s = pthread_getattr_np(pthread_self(), &gattr);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_getattr_np");
> > + errx(EXIT_FAILURE, "pthread_getattr_np: %s", strerror(s));
> > \&
> > printf("Thread attributes:\[rs]n");
> > display_pthread_attr(&gattr, "\[rs]t");
> > @@ -255,37 +256,37 @@ .SS Program source
> > \&
> > s = pthread_attr_init(&attr);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_init");
> > + errx(EXIT_FAILURE, "pthread_attr_init: %s", strerror(s));
> > \&
> > s = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_setdetachstate");
> > + errx(EXIT_FAILURE, "pthread_attr_setdetachstate: %s", strerror(s));
> > \&
> > s = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_setinheritsched");
> > + errx(EXIT_FAILURE, "pthread_attr_setinheritsched: %s", strerror(s));
> > \&
> > stack_size = strtoul(argv[1], NULL, 0);
> > \&
> > s = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stack_size);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "posix_memalign");
> > + errx(EXIT_FAILURE, "posix_memalign: %s", strerror(s));
> > \&
> > printf("posix_memalign() allocated at %p\[rs]n", sp);
> > \&
> > s = pthread_attr_setstack(&attr, sp, stack_size);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_setstack");
> > + errx(EXIT_FAILURE, "pthread_attr_setstack: %s", strerror(s));
> > }
> > \&
> > s = pthread_create(&thr, attrp, &thread_start, NULL);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_create");
> > + errx(EXIT_FAILURE, "pthread_create: %s", strerror(s));
> > \&
> > if (attrp != NULL) {
> > s = pthread_attr_destroy(attrp);
> > if (s != 0)
> > - errc(EXIT_FAILURE, s, "pthread_attr_destroy");
> > + errx(EXIT_FAILURE, "pthread_attr_destroy: %s", strerror(s));
> > }
> > \&
> > pause(); /* Terminates when other thread calls exit() */
> > --
> > 2.50.1
> >
>
> --
> <https://www.alejandro-colomar.es/>
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] man/man3/pthread_attr_init.3: Replace errc
2025-08-20 14:10 ` Dr. David Alan Gilbert
@ 2025-08-20 15:52 ` Alejandro Colomar
0 siblings, 0 replies; 4+ messages in thread
From: Alejandro Colomar @ 2025-08-20 15:52 UTC (permalink / raw)
To: Dr. David Alan Gilbert; +Cc: linux-man
[-- Attachment #1: Type: text/plain, Size: 2141 bytes --]
On Wed, Aug 20, 2025 at 02:10:28PM +0000, Dr. David Alan Gilbert wrote:
> * Alejandro Colomar (alx@kernel.org) wrote:
> > Hi Dave,
>
> Hi Alex,
Hi Dave,
> > On Wed, Aug 20, 2025 at 02:27:25AM +0100, dave@treblig.org wrote:
> > > From: "Dr. David Alan Gilbert" <dave@treblig.org>
> > >
> > > The pthread_attr_init.3 example uses 'errc' to exit on an error
> > > printing the error code. However, 'errc' is a BSDism that Linux
> > > doesn't (and has never?) have.
>
> > Libbsd provides a compatbility layer to provide errc(3bsd) on Linux (and
> > many POSIX systems). libbsd is available in many distros (in Debian,
> > you should install libbsd-dev). BTW, it would be nice if glibc decided
> > to pick this API eventually.
>
> To use that we'd still need to change to:
> #include <bsd/err.h>
With `pkgconf --cflags libbsd-overlay` you get it as <err.h>.
alx@debian:~$ pkgconf --list-package-names | grep libbsd
libbsd-overlay
libbsd-ctor
libbsd
alx@debian:~$ pkgconf --cflags libbsd-overlay
-isystem /usr/include/x86_64-linux-gnu/bsd -DLIBBSD_OVERLAY
It uses some #include_next magic for that.
We could include <bsd/err.h>, although then the examples would
ironically not be portable to the BSDs. :-)
> and tell people to link with -lbsd
Yup, we could show the command for compiling the example, which needs
`pkgconf --cflags --libs libbsd-overlay`.
Maybe... We could include <bsd/err.h>. BSD people will know to remove
that, hopefully. And for the rest, compilation will be as simple as
-lbsd, instead of the pkgconf(1) command.
Feel free to send patches in any of those directions for errc(3).
> TBH using BSD only things in a Linux manpage with a _GNU_SOURCE define
> seems odd. The err()/errc()/errx() family of calls seems to be pretty
> obscure, most [linux] people I checked with had never used them.
It's sad that these function aren't more known. They're quite handy.
> But at least err/errx are in normal glibc.
Yup, that's a good thing. I wish glibc added errc(3) too.
Cheers,
Alex
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-20 15:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 1:27 [PATCH] man/man3/pthread_attr_init.3: Replace errc dave
2025-08-20 8:12 ` Alejandro Colomar
2025-08-20 14:10 ` Dr. David Alan Gilbert
2025-08-20 15:52 ` Alejandro Colomar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.