[comp.unix.questions] A question: Catching "KILL"s.

antek@bioch.tamu.edu (11/04/90)

I'm trying to add a control to a program, which will catch CTRL/C from the
keyboard and "kill" commands. I'm using fortran 77 under MIPS UNIX BSD 4.3

I succeded for "CTRL/C", using the pseudo-code below: 

in "MAIN": 	CALL SIGNAL("ctrl/c signal", ROUTINE, -1)

in "ROUTINE":   CALL AGAIN   ! Reestablish the handler, no recursion in f77.
                DO something, like ask a user, set a common variable etc. 

in "AGAIN":     CALL SIGNAL("ctrl/c signal", ROUTINE, -1)

.. and it chatches CTRL/C and reacts as I want. 

But with the "kill" command things are worse - the "kill process_id" sequence
generates signal # 15 (and this one I want to catch, only). I tried the same
schema as above - but it works only the FIRST time. The second "kill" causes
mostly "Segmentation fault" or similar effects and push the program to exit. 

It seems, the "kill" command is doing something more than just send a signal
- my question is : WHAT ? and:  HOW TO CHEAT the potential murder ? 

Antek @ Bioch.Tamu.Edu