In particular, note that in each pthreads function that takes
a thread ID argument, that ID by definition refers to a thread
in the same process as the caller.
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>
For sched_setaffinity(), the EINVAL error that occurs
if 'cpusetsize' is smaller than the kernel CPU set size only
occurs with kernels before 2.6.9.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
So on a direct syscall, the EINVAL could also occur for bufsiz < 0.
But at the moment, the error text is sufficiently vague
("bufsiz is not positive") that a change to the man page text
is probably not needed.
Simply continuing after an error is in most cases wrong,
and can lead to infinite loops (e.g., for EMFILE).
So handle an error by terminating.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504202
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Olaf van der Spek <olafvdspek@gmail.com>
Fill in some gaps in example code (variable declarations,
adding listening socket to epoll set).
Give variables more meaningful names.
Other minor changes.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504202
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Olaf van der Spek <OlafvdSpek@gmail.com>
Lines for these two characters were added in the previous patch,
but the actual characters were not included in the 4th column
of the table. This fixes that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
The page was phrased in a few places to describe the child as
holding the parent's memory until the child does an execve(2)
or an _exit(2). The latter case should really be the more
general process termimation (i.e., either _exit(2) or abnormal
termination).
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reported-by: Valdis.Kletnieks@vt.edu