tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: killing subshells in /bin/sh scripts



> However, there's another way which comes pretty close - the process group id
> assigned is (in practice, and perhaps required) always the process id of the
> process group leader
I think it's required:
	If the calling process is not already a session leader, setpgrp() sets the process group ID of the calling process to the process ID of the calling process.

> Instead (and here we go beyond posix, but into fairly widely supported
> territory I believe, in that it has been like this a very long time), if
> you send a signal to a negative process ID, it sends the signal to the
> process group that is the absolute value of that ID.
I think this is well-defined:
	For each pid operand, the kill utility shall perform actions equivalent to the kill() function defined in the System Interfaces volume of POSIX.1-2008 called with the following arguments:
	The value of the pid operand shall be used as the pid argument.
	[...]
	pid
		One of the following:
		A decimal integer specifying a process or process group to be signaled. The process or processes selected by positive, negative, and zero values of the pid operand shall be as described for the kill() function. If process number 0 is specified, all processes in the current process group shall be signaled. For the effects of negative pid numbers, see the kill() function defined in the System Interfaces volume of POSIX.1-2008. If the first pid operand is negative, it should be preceded by "--" to keep it from being interpreted as an option.
and
	The kill() function shall send a signal to a process or a group of processes specified by pid. [...]
	If pid is negative, but not -1, sig shall be sent to all processes (excluding an unspecified set of system processes) whose process group ID is equal to the absolute value of pid, and for which the process has permission to send a signal.

Or am I mis-reading something?


Home | Main Index | Thread Index | Old Index