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

Re: Issues with process forking when 'multithreaded'.

Thread Previous | Thread Next
From:
David Mertens
Date:
March 4, 2013 16:01
Subject:
Re: Issues with process forking when 'multithreaded'.
Message ID:
CA+4ieYX0h1-jLnW_O48kArqbUWA5kJ-45RqTza6TR5Airc=Tzw@mail.gmail.com
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 mixing
forks and threads.

As for the details of why this causes trouble, I am not yet familiar enough
with the internals of Perl's threading implementation to answer. Sorry.

David
On Mar 4, 2013 9:32 AM, "Sander Smeenk" <ssmeenk@freshdot.net> wrote:

> Quoting Sander Smeenk (ssmeenk@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 be clear from my original message, the main process
> is the process that creates the threads, one for each server that needs
> to be backed up. Each thread calls fork() only once (through open3) for
> the rsync to do the heavy lifting.
>
> 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).
>
> Amazing there is so little known about what this does / how this works,
> i'll see if i can get a working testcase instead of the snipped i
> pasted.
>
> -Sndr.
> --
> | One tequila, two tequila, three tequila, floor.
> | 4096R/20CC6CD2 - 6D40 1A20 B9AA 87D4 84C7  FBD6 F3A9 9442 20CC 6CD2
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About