Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!spool.mu.edu!agate!stanford.edu!msi.umn.edu!umeecs!hastings.eecs.umich.edu!pfeif From: pfeif@hastings.eecs.umich.edu (Stephen G Pfeiffer) Newsgroups: comp.lang.perl Subject: catching the suspend signal Message-ID: <1991Jun28.173535.3346@zip.eecs.umich.edu> Date: 28 Jun 91 17:35:35 GMT Sender: usenet@zip.eecs.umich.edu (Mr. News) Organization: University of Michigan EECS Dept. Lines: 44 Hello perl programmers and hacks. Can someone help me out with a suspend signal catching subroutine. What I want is to be able to catch the ^Z or suspend signal from the shell, perform a subroutine and then perform the actual suspend. I have some code below. The problem seems to be that even after I set the SIG{'TSTP'}= 'DEFAULT'; and kill the pid of the script, the subroutine has to return or fall off the end, before the actual suspend will occur. This means that I cannot reset the $SIG variable to my suspend handler. I would like to be able to suspend and bring-to-the-forground as many times as necessary while still handling the suspend signal. Presently, I am only able to do it once (remove the last SIG statement to get this effect). #!/usr/local/bin/perl $SIG{'TSTP'} = 'sushandler'; # SOME code, who cares what. # . # . # . # . # . # This is what I want, but it doesn't work quite right. The subroutine # finishes, before the suspend is done. sub sushandler { print "Hey, I caught a suspend signal......\n"; $SIG{'TSTP'} = 'DEFAULT'; kill 'TSTP', $$; $SIG{'TSTP'} = 'sushandler'; } Thanks for any help. -pfeif- (Stephen G. Pfeiffer @ Departmental Computing Organization UofM) e-mail: pfeif@hastings.eecs.umich.edu