01-29-04 04:34 PM
I know that it's generally a bad idea for a thread in a multithreaded
processes to call fork(), at least under Linux 2.4. Is it still a bad
idea if the child process immediately calls exec()? How about if it
calls dup2() and then execs? If not, what are the problems?
Context: I have a threaded program, not of my own creation, in which
several threads (10-40) act as filters on a huge amount of data (over
1 GB). Currently this program is dependent on the data coming through
the pipes in sorted order. In order to remove this restriction, I'd
like each of these threads to fork off a /bin/sort process.
(Unfortunately, trying to fork off the proper number of sort proceses
before the first call to pthread_create() isn't feasible, not without
a huge rewrite. The idea here is to avoid doing major surgery on this
code, which is non-trivial and wholly uncommented.)
b
[ Post a follow-up to this message ]
|