fork timing hole???...

rml at hpfcla.UUCP rml at hpfcla.UUCP
Fri Aug 23 04:01:00 AEST 1985


>         In 3) the signal arrives between when the parent shell enters fork()
> and the new process is created (specifically before its process group is
> filled in in its proc entry). 
> 
> The main reason for this is that newproc() doesn't copy pending signals from
> the parents proc entry to the child.
> 
> Finally, my question ..... Is this a bug??

It does seem like a bug, although a rather minor one in practice.  In
the scenario you give, when the window is hit, most likely either

	a) the command which wasn't killed completes and the user
	   doesn't mind
or
	b) the user hits the interrupt key again to kill it.

Since there we're dealing with human reaction times here, there doesn't
seem to be any real harm done.  In a similar scenario with another
process sending a signal to the process group with kill(2), the bug
might be more severe.

> And the next, as yet unanswered question .... Should children inherit pending
> signals?? .... Will it do any harm??

No, I don't think children should inherit pending signals.  In this
particular case the signal was sent to the entire process group, and
thus it could be interpreted as being intended for the child as well.
However, ALL pending signals can include signals which have been
specifically sent to the parent process by kill(2).  If the child
inherited signals we would again have three possible situations:

	1) parent receives signal before fork
	2) parent receives signal after fork
	3) parent and child both receive signal

with the third being an anomaly caused by hitting a small window.  The
kernel currently has no way to distinguish signals sent to an individual
process from those sent to a process group (or to pid -1).  I suppose
such a mechanism could be added and the appropriate signals could be
passed across forks, but I'm not sure it would be worthwhile.

Also, inheriting signals across forks would have more impact on systems
which allow masking of signals (mainly 4.2 and those with signal
mechanisms based on 4.2).  On those systems the set of pending signals
is not limited to those arriving in the small window during fork.  It
could be argued that this would provide more correct semantics, but it's
not compatible with existing systems.

			Bob Lenk
			{hplabs, ihnp4}!hpfcla!rml



More information about the Comp.unix.wizards mailing list