Hi:
The fork() man page says the following. Is this for 6.2? It seems to be a
very constraining caveat!!
Any idea about how one can achieve it: fork when there are multiple threads
(actually only 2 threads) present?
Caveats:
Currently, fork() is supported only in single-threaded applications. If you
create a thread and then call fork(), the function returns -1 and sets errno
to ENOSYS.
Hi:
The fork() man page says the following. Is this for 6.2? It seems to be a
very constraining caveat!!
Any idea about how one can achieve it: fork when there are multiple threads
(actually only 2 threads) present?
Caveats:
Currently, fork() is supported only in single-threaded applications. If you
create a thread and then call fork(), the function returns -1 and sets errno
to ENOSYS.
Thanks,
Rommel
\
–
Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll – http://qnx.wox.org/
Nope. You have to call fork() before any threads are created. If you
want to fork()/exec() use spawn*() instead.
chris
Rommel Dongre <> rdongre@pillardata.com> > wrote:
Hi:
The fork() man page says the following. Is this for 6.2? It seems to be
a
very constraining caveat!!
Any idea about how one can achieve it: fork when there are multiple
threads
(actually only 2 threads) present?
Caveats:
Currently, fork() is supported only in single-threaded applications. If
you
create a thread and then call fork(), the function returns -1 and sets
errno
to ENOSYS.
Thanks,
Rommel
\
Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll – http://qnx.wox.org/
Is it possible to kill all the threads except the main and then fork()
successfully?
Offically, no. The caveat is accurate – the use of fork() and pthreads
are mutually exclusive, in the same process. The state of libc’s
mutexes/condvars are undefined in the child process.
If you want to be dirty and nasty, the code for fork() from libc will give
you a hint of how you could accomplish this. I really don’t recommend it
though.
Kris
pid_t fork(void) { #if 1 // @@@ TEMPORARY until libc is fork safe wrt mutexs
extern int _Multi_threaded;
Rommel Dongre <> rdongre@pillardata.com> > wrote:
Is it possible to kill all the threads except the main and then fork()
successfully?
Offically, no. The caveat is accurate – the use of fork() and pthreads
are mutually exclusive, in the same process. The state of libc’s
mutexes/condvars are undefined in the child process.
If you want to be dirty and nasty, the code for fork() from libc will give
you a hint of how you could accomplish this. I really don’t recommend it
though.
BUYER BEWARE! THIS IS MOST CERTAINLY GUARANTEED TO BREAK IN
THE FUTURE. THIS IS NOT RECOMMENDED.
Thanks,
Thomas
pid_t fork(void) { #if 1 // @@@ TEMPORARY until libc is fork safe wrt mutexs
extern int _Multi_threaded;
Offically, no. The caveat is accurate – the use of fork() and pthreads
are mutually exclusive, in the same process. The state of libc’s
mutexes/condvars are undefined in the child process.
Kris Warkentin <> kewarken@qnx.com> > wrote:
If you want to be dirty and nasty, the code for fork() from libc will
give
you a hint of how you could accomplish this. I really don’t recommend
it
though.
BUYER BEWARE! THIS IS MOST CERTAINLY GUARANTEED TO BREAK IN
THE FUTURE. THIS IS NOT RECOMMENDED.
Thanks,
Thomas
pid_t fork(void) { #if 1 // @@@ TEMPORARY until libc is fork safe wrt mutexs
extern int _Multi_threaded;
Offically, no. The caveat is accurate – the use of fork() and
pthreads
are mutually exclusive, in the same process. The state of libc’s
mutexes/condvars are undefined in the child process.
Rommel Dongre <rdongre@pillardata.com> wrote:
: A pointer to spawn on the fork() page that talked about the caveat would
: have been really helpful on the online documentation!!
I’ll pass this on to the writer who looks after this book. Thanks for the
suggestion.
: “David Gibbs” <dagibbs@qnx.com> wrote in message
: news:av2bcc$1ts$1@nntp.qnx.com…
:> Rommel Dongre <rdongre@pillardata.com> wrote:
:> > Hi:
:> > Is it possible to spawn() from a multi-threaded app?
:>
:> Yes, it is. That is the usual solution.
Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems