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

Issues with process forking when 'multithreaded'.

Thread Next
Sander Smeenk
March 5, 2013 03:24
Issues with process forking when 'multithreaded'.
Message ID:

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 why this happens, but i can reproduce it
so there must be something wrong somewhere. ;)

What am i seeing:

1) waitpid() sometimes returns the $PID for the child process (as if
   it was reaped) while the child process is still running.

2) waitpid() sometimes returns -1 instead of the correct values for the
   exit state of a child process while the child process ran perfectly

Again, all this only happens when running multiple 'threads'.
Refer to for a codesnipet from the
subroutine which runs as a thread which in turn spawns rsync.

Besides these waitpid() issues, the threaded code seems to run just fine
and no other abnormalities are found.

This is Perl 5.14.2 with ithreads on Ubuntu GNU/Linux, AMD64.
Perhaps this all sounds familiar to any of you? 

Please let me know if more input or code is required!

With regards,
| 1 1 was a racehorse, 2 2 was 1 2, 1 1 1 1 race 1 day, 2 2 1 1 2
| 4096R/20CC6CD2 - 6D40 1A20 B9AA 87D4 84C7  FBD6 F3A9 9442 20CC 6CD2

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