Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: problems with fork from thread

by zentara (Archbishop)
on Mar 01, 2012 at 19:37 UTC ( [id://957297]=note: print w/replies, xml ) Need Help??


in reply to problems with fork from thread

I havn't run your code, but from the discussion, I suspect your problem may be a waitpid problem when you fork from the threads. I would try putting
$SIG{CHLD} = 'IGNORE';
in both the main thread and the spawned threads. See Best way to kill a child process for more discussion.

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: problems with fork from thread
by Eliya (Vicar) on Mar 01, 2012 at 21:04 UTC

    I don't think this would help, because (according to my tests) it's the child processes that hang in a FUTEX_WAIT (as nothing seems to be calling FUTEX_WAKE again any more):

    7160 futex(0x808248, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...> 7162 futex(0x808248, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...> 7164 futex(0x808248, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...> ...

    (filtered strace output)

    Also, the results vary structurally (not only quantitatively) with the number of threads started, whether you run the script under strace, etc., so I suspect it's some race condition issue.  In other words, a varying number of children simply don't terminate, so there are no corresponding SIGCHLD signals.

    Unfortunately, I don't know enough about Perl's thread implementation to be of any real help here...

    So, until someone more knowledgable in the area has found sufficient motivation and time to tackle those issues, I'd stick with the common recommendation to stay away from mixing threads with fork.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://957297]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-18 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found