Funny kill -9 behaviour

Chris Torek chris at mimsy.umd.edu
Sun Aug 19 09:11:28 AEST 1990


In various articles various people ask why

	kill -9 `some expression`

produces

	`some expression`: Ambiguous

The reason is that kill is a C-shell built-in, these people are using
the C-shell, and the C-shell is (to an amazingly large extent, given
that it `works' for most uses) quite thoroughly broken inside.  The
kill code expands the backquote expression, finds that it breaks into
several words, and complains (instead of iterating over each of the
words).  This does not happen with

	kill -9 several words

because here the expansion occurs before the built-in kill function.

Note that kill *must* be a built-in, since `kill %2' has to convert the
`%2' to a `job' (and %n does not normally expand to a list of process
IDs, which is the obvious way to do this without a built-in).

So: workarounds:

	eval kill arguments `expression`

	/bin/kill arguments `expression`

The latter runs one more process, does not interpret `%'s, and is
dependent on the location of the `kill' program.  The former simply
causes the backquote expression to be expanded before calling the
internal `kill' routine.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris
	(New campus phone system, active sometime soon: +1 301 405 2750)



More information about the Comp.unix.questions mailing list