Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Proposal how to make modules using fork more portable

by BrowserUk (Patriarch)
on Mar 30, 2011 at 12:14 UTC ( [id://896401]=note: print w/replies, xml ) Need Help??


in reply to Proposal how to make modules using fork more portable

Personally, I would translate any normally fatal signal into a direct call to TerminateThread() if the process ID that is the subject of the signal is a pseudo-process ID.

Whilst TerminateThread() is usually a bad thing, given the aim here is to allow the main thread to get past a wait or waitpid and exit the process, when the thread will be summarily abandoned anyway, it amounts to the same thing.

The advantage is that you supply TerminateThread() with an exit code, which will then be reported back (via GetExitCodeThread()) as if it were the return value from the thread proc in the normal way, hence to the the rest of perl, and the program, it will seems as if the thread just ended.

Of course, clean-up will not have been done, so it will likely leak like a bitch and possibly cause deadlocks through unreleased semaphores, mutexes and critsecs. But if the goal is just to allow the main process to terminate, that doesn't matter.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Proposal how to make modules using fork more portable

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (None)
    As of 2024-04-25 01:21 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found