more useful options | |
PerlMonks |
Re: Re: Re: My pipe gets the SIGINT. And I dont want that...by mikfire (Deacon) |
on Apr 27, 2001 at 00:58 UTC ( [id://75905]=note: print w/replies, xml ) | Need Help?? |
This is gonna require some fork games and some fun signal handling.
I should publish the standard warnings that perl's signal
handling leaves a lot to be desired and do not blame me
if this causes all your hair to fall out and sets your
workstation on fire :)
Basically, what I am going to do is to spawn the PIPE process off as a child process. The parent process will watch for two signals: SIGINT will cause the parent to kill the child off and SIGHUP will cause the parent to kill the child and then itself. To avoid perl's signal problems, I am keeping the handlers very, very simple - they each set a variable and let the main loop handle it. There are still race conditions in the code, which may or may not be able to be fixed. Also, not to put too much of a point on it, I am not using a SIGCHLD handler. I use waitpid and reap the children myself. I am also gonna do this a bit of pseudo-code here - I am currently too lazy to cut'n'paste :)
This is untested, but there is also a lot of code to be found on perlmonks dealing with forking and reaping child processes. I have a very extensive example playing games like this but do not have the source code immediately available. I will check when I get home and make sure this example is mostly correct. Mik mikfire
In Section
Seekers of Perl Wisdom
|
|