Issues with process forking when 'multithreaded'.

2013-03-04 Thread Sander Smeenk
Hi, I'm new on this list, not sure if this is the right place for this, please redirect me if this is not on topic here. ;) I am seeing issues with open3()/waitpid() calls when running the same code as multiple threads - this does not happen with a single thread running the code - i'm not sure wh

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread 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. On Mon, Mar 4, 2013 at 9:25 AM, Sander Smeenk wrote: > Hi, > > I'm new on this list, not sure

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread Sander Smeenk
Quoting Jerry D. Hedden (je...@hedden.us): > 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

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread Sander Smeenk
Quoting Sander Smeenk (ssme...@freshdot.net): > 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. ;) Also, this might not b

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread David Mertens
Sander, Would it be possible to use the "forks" module? It is supposed to provide a drop-in replacement for "threads" on operating systems that support posix forks, which would be true in your case. I suspect this would cure your problems, since everything would operate using forks instead of mixi

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread Sander Smeenk
Quoting David Mertens (dcmertens.p...@gmail.com): > Would it be possible to use the "forks" module? It is supposed to provide a > drop-in replacement for "threads" on operating systems that support posix > forks, which would be true in your case. I suspect this would cure your > problems, since ev

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread Mike Pomraning
On Mon, Mar 4, 2013 at 10:31 AM, Sander Smeenk wrote: > > And i still don't understand why mixing threads+fork is "not smart". ;) > Mixing the two makes it easy to introduce damning error. Here's someone who learned it the hard way: http://rachelbythebay.com/w/2011/06/07/forked/ Here are some

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread Dave Mitchell
On Mon, Mar 04, 2013 at 04:32:13PM +0100, Sander Smeenk wrote: > So, it's not a fork() from the main process (which would perhaps > copy all threads to the fork()ed process, or maybe not, who knows). fork() on linux creates a single thread in the child process, but copies the memory and state of *

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread Sander Smeenk
Quoting Mike Pomraning (m...@pilcrow.madison.wi.us): > > And i still don't understand why mixing threads+fork is "not smart". ;) > Mixing the two makes it easy to introduce damning error. > > Here's someone who learned it the hard way: > http://rachelbythebay.com/w/2011/06/07/forked/ > > Here ar

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread Sander Smeenk
Quoting Dave Mitchell (da...@iabyn.com): > > So, it's not a fork() from the main process (which would perhaps > > copy all threads to the fork()ed process, or maybe not, who knows). > fork() on linux creates a single thread in the child process, but copies > the memory and state of *all* threads.

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread Paul Robert Marino
take a look at what I did in MrTools http://sourceforge.net/projects/mrtools/ specifically mrsync.pl http://mrtools.svn.sourceforge.net/viewvc/mrtools/mrtools/trunk/mrsync.pl?revision=32&view=markup Its not perfect but it works fairly well I stopped looking at return codes and just looked at the st

Re: Issues with process forking when 'multithreaded'.

2013-03-04 Thread David Mertens
No, no, I mean the module called "forks" from cpan: https://metacpan.org/module/forks#same-API-as-threads Drop-in replacement for threads, including shared data handling. I but that would solve your problem satisfactorily. David On Mon, Mar 4, 2013 at 10:31 AM, Sander Smeenk wrote: > Quoting

Issues with process forking when 'multithreaded'.

2013-03-04 Thread Sander Smeenk
Hi, I'm new on this list, not sure if this is the right place for this, please redirect me if this is not on topic here. ;) I am seeing issues with open3()/waitpid() calls when running the same code as multiple threads - this does not happen with a single thread running the code - i'm not sure wh