[comp.bugs.misc] Korn shell leaves phantom jobs -BSD

rad@tekgen.TEK.COM (Richard Doty) (02/03/88)

Subject: Korn shell leaves phantom jobs -BSD
Index:	sh/jobs.c

Description:
	If a korn shell with the monitor option set is interrupted
	during a macro expansion (e.g.  eval `tset -Tvt100 ...` ), a
	job is left on the jobs stack.  This is a "pipejob" so 'jobs'
	does not see it, but if this happens to a login shell (perhaps
	while processing your .profile), you will get the "you have
	running jobs" message when you try to log out.

Repeat-By:
	Put a macro expansion in your .profile, and interrupt it
	while logging in.  Then try to log out.

Fix:
	The fix I use is to have list_jobs detect the case where a
	pipejob has been waited for (the NOTIFY bit is set), but has no
	associated job leader (job_bynum() returns NULL).  If that happens,
	I assume it is a bogus job table entry, and unpost it.

	This still looks like a kludge, but I think it is because of the
	dual use of the P_PIPEJOB flag - these macro jobs shouldn't be
	post()ed in the first place.