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 <ssme...@freshdot.net> wrote:

> 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 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
>    fine.
>
> Again, all this only happens when running multiple 'threads'.
> Refer to https://8n1.org/raw/8750/71a3 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,
> -Sander.
> --
> | 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
>

Reply via email to