glibc/NetBSD/FreeBSD follow a naming convention for these
functions that unfortunately differs from that originally
established by OpenBSD's implementation.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Previously, the page said this function suffered the same
problems as strtok(), but in fact strsep() doesn't suffer
from all of the same problems as strtok(), so explicitly
list just the problems of strsep() in the strsep.3 page.
Reported-by: Marc Lehmann <schmorp@schmorp.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Document functions (new in glibc 2.9) for conversion between
host byte order and big-/little- endian byte order:
htobe16(), htole16(), be16toh(), le16toh(),
htobe32(), htole32(), be32toh(), le32toh(),
htobe64(), htole64(), be64toh(), le64toh()
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Note that siglongjmp() only restores signal mask if, and only
if, 'savesigs' argument of sigsetjmp() was non-zero. (Previous
text omitted the "and only if".)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Also: rewrite some text describing the /etc/hostid file, so that
this location is referred to just once on the page.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
The interfaces documented in this page are purely glibc.
Reported-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
http://sourceware.org/bugzilla/show_bug.cgi?id=7075
Some existing code relies on techniques like the following to
append text to a buffer:
$ cat s.c
#include <stdio.h>
char buf[80] = "not ";
main()
{
sprintf(buf, "%sfail", buf);
puts(buf);
return 0;
}
$ cc s.c
$ ./a.out
not fail
However, the standards say the results are undefined if source
and destination buffers overlap, and with suitable compiler
options, recent changes can cause unexpected results:
$ cc -v 2>&1 | grep gcc
gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036] (SUSE Linux)
$ cc -D_FORTIFY_SOURCE -O2 s.c
$ ./a.out
fail
Reported-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Glibc's bindresvport() takes no notice of sin->sin_port:
it always returns an arbitrary reserved port in the
anonymous range (512-1023). (Reported by Mats Wichmann.)
Also:
* Add EADDRINUSE and EACCES errors.
* Mention use of getsockname(2).
* Other minor rewrites and reorderings of the text.
* Explicitly note that glib's bindresvport() ignores
sin->sin_port.
* Change license There's now virtually no text remaining from
the 1.70 version of this page.
Reported-by: Mats Wichmann <mats.d.wichmann@intel.com>
Reviewed-by: Mats Wichmann <mats.d.wichmann@intel.com>
Reviewed-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Clean up the $LANGUAGE description, by removing bogus comments
from setlocale(3) and expanding the mention in locale(7).
Maybe you will decide that a more detailed description should be left
to the gettext(3) documentation, but I actually care about the invisible
part of the patch more since the comments have put me off the track
initially ($LANGUAGE has nothing to do with setlocale(3) and is
completely isolated to gettext, as obvious from the glibc sources).
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
dladdr() will act unexpectedly if called from non-pic code on a
compile-time-generated function pointer:
/* test_dladdr.c */
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
int
main(void)
{
void *func;
Dl_info info = {};
func = printf;
dladdr(func, &info);
printf("%s at %p resolved from %s\n", info.dli_sname,
func, info.dli_fname);
return 0;
}
$ cc test_dladdr.c -ldl
$ ./a.out
printf at 0x804838c resolved from ./a.out
$ cc -fPIC test_dladdr.c -ldl
$ ./a.out
_IO_printf at 0xb7f71c30 resolved from /lib/libc.so.6
In the long term, it might make sense to make dladdr() recognize
plt pointers and recurse, but I'm too afraid of Ulrich ;-)
(and he seems to be heavy proponent of pic code anyway, so
the chances for that to be accepted probably aren't high).
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This patch documents the order of the getaddrinfo(3) results
(RFC 3484), how should the application deal with that,
mentions the extremely common cause of having multiple
results per query (both IPv4 and IPv6 addresses available)
and mentions /etc/gai.conf.
(mtk: Minor tweaks, and note glibc version for /etc/gai.conf)
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
If an exit handler itself calls exit(3), the results are
undefined (see the POSIX.1-2001 specification of exit(3)).
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
According to POSIX.1, using longjmp() to terminate execution of
a function registered using atexit() produces undefined results.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
According to POSIX.1, using longjmp() to terminate execution of
a function registered using atexit() produces undefined results.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
It's a subtle point, but if a registered function itself
calls exit(3), then subsequent functions that were registered
with on_exit(3) will see the exit status given to the more
recent exit(3) call.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Many sockets man pages use the name 'sockfd' already.
For consistency, changes the others to do so as well.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
The correct range for the return value is [-pi/2,pi/2].
(mtk's fix in the last change to the return value text was
a botch-up of a (correct) suggestion by Nicolas Francois.)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Loic Domaigne suggested some rewordings of the NOTES paragraph
that discusses the utility of asynchronous cancelability.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reviewed-by: Loic Domaigne <tech@domaigne.com>
Many pages still mention use of the obsolete sysctl(2) system
call, or used the term "sysctls"; rewrite these mentions to
instead be in terms of /proc interfaces.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
The range is not [-pi/2, pi/2], but [-pi, pi].
(mtk: This error was reported by Nicolas Francois, and
should have been fixed in 3.11, but somewhere along the way,
the fix got lost.)
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506299
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
In EXAMPLE, note that PTHREAD_INHERIT_SCHED is the default for
the inherit scheduler attribute attribute.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Loic Domaigne <tech@domaigne.com>
Loic Domaigne points out that if a system implements
SCHED_SPORADIC (which Linux does not), then other
fields are also specified in sched_param. The simple
solution is just to remove that phrase from the man
page.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Loic Domaigne <tech@domaigne.com>
The SYNOPSIS shows types for arguments and return values, but
these are really just suggestions: since the interfaces are
macros, the compiler won't catch all violations of
the "type rules". Warn the reader of this.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
After review comments by Bert Wesarg:
* Explain that cpu_set_t is a bitset, but should be considered
opaque.
* A CPU set can be duplicated with memset().
* Size of a CPU set is rounded up to size of long.
* CPU_SETSIZE is in bits, but the setsize argument is in bytes.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Bert Wesarg <bert.wesarg@googlemail.com>
Reviewed-by: Bert Wesarg <bert.wesarg@googlemail.com>
These macros return twice what they should because of thinko
in glibc 2.8 and earlier. The bug is fixed for glibc 2.9.
http://sourceware.org/bugzilla/show_bug.cgi?id=7029
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This page contains material moved out of sched_setscheduler(2).
It overwrites a previously existing link file with the same name.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Masanari notes that this is an FAQ for logger(1) and that
Solaris and FreeBSD document this point in syslog(3).
The glibc info page also hides this comment in its source:
Internally, there is also LOG_KERN, but LOG_KERN == 0,
which means if you try to use it here, just selects default.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
(After a suggestion by Vegard Nossum.)
Also made a few other small rewordings to in the initial
paragraph.
Reported-by: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Many older pages use a handle_error() macro to do simple
error handling from system and library function calls.
Switch these pages to do similar.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Glibc switched to using a POSIX-specified error code for
this error case.
http://bugs.linuxbase.org/show_bug.cgi?id=2375
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Acked-by: Stew Benedict <stewb@linux-foundation.org>
Passing pointer arguments to makecontext() is possible,
but only on some architectures, and with no guarantees
of portability.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504699
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Paul Evans <leonerd@leonerd.org.uk>
The page was a bit fuzzy in describing the return values for
various cases. In particular, it needed to be more explicit
in describing what happens for the "not found" case.
This is an analogous change to the previous change for
getpwnam.3, made after Andreas Henriksson's report.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504787
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
The page was a bit fuzzy in describing the return values for
various cases. In particular, it needed to be more explicit
in describing what happens for the "not found" case.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504787
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Andreas Henriksson <andreas@fatal.se>
The page was a bit fuzzy in describing the return values for
various cases. In particular, it needed to be more explicit
in describing what happens for the "not found" case.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504708
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Andreas Henriksson <andreas@fatal.se>
According to POSIX.1-2001, the CLOCK_PROCESS_CPUTIME_ID and
CLOCK_THREAD_CPUTIME_ID clocks should be settable, but
currently they are not.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Rework the text that refers to sched_setscheduler(2) for
a description of the permissions required to change
the scheduling policy and priority.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
On MacOS X at least, pthread_attr_setstacksize(3) can fail
with EINVAL if 'stacksize' is not a multiple of the system
page size. Best to mention this so as to aid people writing
portable programs.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Karsten Weiss <knweiss@gmail.com>
==
From: Karsten Weiss <knweiss@gmail.com>
Date: Fri, Oct 31, 2008 at 3:46 PM
Subject: pthread_create(3) - example bug + problems
[...]
A look in the pthread_set_stacksize man page on Mac revealed that on
Mac the stack size must not only be at least PTHREAD_STACK_MIN...
[...]
...but the new stack size must also be a multiple of the system page
size!
From pthread_attr_setstacksize(3):
pthread_attr_setstacksize() will fail if:
[EINVAL] Invalid value for attr.
[EINVAL] stacksize is less than PTHREAD_STACK_MIN.
!!! [EINVAL] stacksize is not a multiple of the system page size.
See for yourself (PTHREAD_STACK_MIN==8192 on Mac OS X):
$ ./pthread_test -s $((8192*10-1)) a
pthread_attr_setstacksize: Invalid argument
$ ./pthread_test -s $((8192*10)) a
Thread 1: top of stack near 0xb0014f6c; argv_string=a
Joined with thread 1; returned value was A
$ ./pthread_test -s $((8192*10+1)) a
pthread_attr_setstacksize: Invalid argument
The bug is in this part of the code:
/* Allocate memory for pthread_create() arguments */
tinfo = calloc(num_threads, num_threads);
if (tinfo == NULL)
errExit("calloc");
The calloc() line should read like this instead:
tinfo = calloc(num_threads, sizeof(struct thread_info));
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Add text to CONFORMING TO explaining that the "_np"
suffix is because these functions are non-portable.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Karsten Weiss <K.Weiss@science-computing.de>
EFAULT can't occur for these functions. EINVAL can occur
for invalid 'attr' or 'cpuset' arguments.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
s/\.R " "/\\\&/ as a way of getting a blank line after a .SS heading.
(Suggested by Sam Varshavchik <mrsam@courier-mta.com>)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
(This mirrors the previous change to getdents.2)
Some file systems provide partial support for 'dt_type',
returning DT_UNKNOWN for cases they don't support.
Update the discussion of 'd_type' and DT_UNKNOWN to
support this.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Clarify the description of some errors by giving examples
that produce the errors. (Text added for EAI_SERVICE and
EAI_SOCKTYPE.)
Also, add an error case for EAI_BADFLAGS.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: J.H.M. Dassen (Ray) <fsmla@xinara.org>
Move the shell session text that demonstrates the use of
the example program so that it precedes the actual
example program. This makes the page consistent with the
majority of other pages.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Add ".SS Program source" to clearly distinguish shell session and
descriptive text from actual program code.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Make it clear that LD_LIBRARY_PATH is inspected *once*, at
program start-up. (Verified from source and by experiment.)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Michael B. Trausch <mike@trausch.us>