[comp.unix.programmer] Writing a program that cannot be killed except by reboot

mcgough@wrdis01.af.mil (Jeffrey B. McGough) (04/15/91)

Is there anyway to block ALL signals to a program so that it
may not be killed by kill???

I know the manual says that sig 9 may not be caught or blocked
but I was wondering if there might be a funny (strange, interesting)
hack to get around this...

thanks,
-- 
Lator,                                       We cheat the other guy,
                                             and pass the savings on to you.
Jeffrey B. McGough
WR-ALC UNIX Systems Administrator                    (mcgough@wrdis01.af.mil)

akbloom@aplcen.apl.jhu.edu (Keith Bloom) (04/15/91)

mcgough@wrdis01.af.mil (Jeffrey B. McGough) writes:

>Is there anyway to block ALL signals to a program so that it
>may not be killed by kill???

>I know the manual says that sig 9 may not be caught or blocked
>but I was wondering if there might be a funny (strange, interesting)
>hack to get around this...

I've seen situations in which the program is trying to write to some
device like a network socket or parallel or serial port, and there's
something wrong with the connection.  In this case, it frequently
happens that even kill -9 won't work; rebooting is the only thing *I*
can think of to do when this happens.  I suppose a program could do this
deliberately.

By the way, is there any *legitimate* reason for a device driver to
simply "hang" forever?  In other words, is this ever *not* a bug in
the device driver?

jik@athena.mit.edu (Jonathan I. Kamens) (04/15/91)

In article <1991Apr14.200931.17551@aplcen.apl.jhu.edu>, akbloom@aplcen.apl.jhu.edu (Keith Bloom) writes:
|> mcgough@wrdis01.af.mil (Jeffrey B. McGough) writes:
|> >Is there anyway to block ALL signals to a program so that it
|> >may not be killed by kill???
|> 
|> I've seen situations in which the program is trying to write to some
|> device like a network socket or parallel or serial port, and there's
|> something wrong with the connection.  In this case, it frequently
|> happens that even kill -9 won't work; rebooting is the only thing *I*
|> can think of to do when this happens.  I suppose a program could do this
|> deliberately.

  While the program is hung in the device driver, it is running in the kernel,
not in the user code, which means it can't do any work at all.  I don't see
much use for a process that can't be killed but can't do any work either.  The
second the device driver exits and the program is able to work again, it can
be killed.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710

marco@ghost.unimi.it (Marco Negri) (04/15/91)

mcgough@wrdis01.af.mil (Jeffrey B. McGough) writes:

>Is there anyway to block ALL signals to a program so that it
>may not be killed by kill???

>I know the manual says that sig 9 may not be caught or blocked
>but I was wondering if there might be a funny (strange, interesting)
>hack to get around this...

	I know one and only one situation in that a process can't be killed
	with SIGKILL signal.
	When it is slept, in kernel mode, with priority < PZERO.
	The second argument of sleep kernel is the "sleep priority".
	If this priority is less than PZERO *all* signal are ignored, but
	the process is slept, not ready.
	Don't exist any method to caugth signal 9 without sleeping the
	process forever (reboot).
	Bye. Marco
-- 
Marco Negri					Phone  : +39-2-7575242
Computer Science Dep. Milan University 		Fax    : +39-2-76110556
Via Moretto da Brescia, 9			Telex  : 335199 - MIDSII
I-20133 Milano - Italy - `92 Europe		E-Mail : marco@ghost.unimi.it

sleepy@wybbs.mi.org (Mike Faber) (04/17/91)

In article <444@wrdis01.af.mil> mcgough@wrdis01.af.mil (Jeffrey B. McGough) writes:
>Is there anyway to block ALL signals to a program so that it
>may not be killed by kill???
>I know the manual says that sig 9 may not be caught or blocked
>but I was wondering if there might be a funny (strange, interesting)
>hack to get around this...

How about # rm /bin/kill  :-)

--
sleepy@wybbs.uucp
Michael Faber

tom@sco.COM (Tom Kelly) (04/18/91)

In <1991Apr15.113041.3069@ghost.unimi.it> marco@ghost.unimi.it (Marco Negri) writes:

> mcgough@wrdis01.af.mil (Jeffrey B. McGough) writes:
> 
> >Is there anyway to block ALL signals to a program so that it
> >may not be killed by kill???
> 
> >I know the manual says that sig 9 may not be caught or blocked
> >but I was wondering if there might be a funny (strange, interesting)
> >hack to get around this...
> 
> 	I know one and only one situation in that a process can't be killed
> 	with SIGKILL signal.
> 	When it is slept, in kernel mode, with priority < PZERO.

There is another way, although it is not very useful.  If a process
is ptraced, a SIGKILL delivered to it will cause it to stop and
awaken its parent.  The parent can continue the process without
delivering the signal, which can cause the process to appear unkillable.
Of course, the parent can be killed.

Tom Kelly  (416) 922-1937
SCO Canada, Inc. (formerly HCR) 130 Bloor St. W., Toronto, Ontario, Canada
{utzoo, utcsri, uunet}!scocan!tom or tom@sco.com

flee@cs.psu.edu (Felix Lee) (04/24/91)

> If a process is ptraced, a SIGKILL delivered to it will cause it to
> stop and awaken its parent.

Hmm.  Then it may be possible for two procesess to mutually ptrace
each other (using PTRACE_ATTACH) such that they both intercept and
ignore KILL signals.  You can still stun the processes if you can
deliver signals to both of them quickly enough.
--
Felix Lee	flee@cs.psu.edu