develooper Front page | perl.ithreads | Postings from March 2013

Re: Issues with process forking when 'multithreaded'.

Thread Previous | Thread Next
Sander Smeenk
March 4, 2013 15:17
Re: Issues with process forking when 'multithreaded'.
Message ID:
Quoting Jerry D. Hedden (

> For the most part, threads and forks are not compatible.  Therefore, you
> probably cannot use open3()/waitpid() in a threaded application.  If you
> google 'perl fork threads', you'll find lots more info.

I kind of expected this reply. :>

I did read about "it not being smart to mix fork() and threads". This
comes down to portability issues and unexpected results on different
platforms.  With this project i don't care about portability.
This should run on my GNU/Linux AMD64 system only. :)

At the same time fork()ing from a thread is allowed, doesn't raise
warnings and no-one can tell me exactly why it can not work (everyone
tells me 'it is not smart'). 

In fact, it does work, for 95% of all threads it works as designed, only
a select few (but not the same) threads fail each time, i was hoping to
find out why only this small portion of threads fail their waitpid() call. ;)

I'll start reworking this with pure fork()s. Have to look into some IPC
way of getting the output from the childs back in the main process.

Thanks so far,
| Man who lose watch in toilet bound to have shitty time.
| 4096R/20CC6CD2 - 6D40 1A20 B9AA 87D4 84C7  FBD6 F3A9 9442 20CC 6CD2

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About