Subject: jobs output from /bin/sh
To: None <tech-userlevel@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-userlevel
Date: 10/17/2002 18:28:30
I've been fixing /bin/sh so that the output from 'jobs' obeys the
posix rules <1>.  This is all ok until you come to the job status that
is written out when a job stops running - posix requires the output,
but doesn't specify the format!

There are three (at least) places when the output is required:
1) when a job is stopped (eg by typing ^Z)
2) when an asynchronous job terminates
3) when a synchronous job exits from a signal (except INT or PIPE)

Testing with commands like 'sleep 30 | sleep 20 | sleep 30', and
doing a 'kill -quit' on the pid of the 'sleep 20' shows that:

The netbsd /bin/sh outputs (in each case):
1) '%1 Suspended' once for each process in the job
2) '[1] <pid> Exit 0   <command line>', one line per process
3) 'Quit - core dumped' when the process exits (not when job is done)

Now it seems to be that the output should always be in the form
required by posix (like (2) above), so the output would be:
1) '[1] + Suspended               sleep 30 | sleep 20 | sleep 30'
2) '[1]   Done                    sleep 30 | sleep 20 | sleep 30'
3) '[1]   Quit (core dumped)  <command>' for a single process,
   '[1]   Done                    sleep 30 |
	  Quit (core dumped)      sleep 20 |
	  Done                    sleep 30'
    for the suggested pipeline.

This ought to make it much easier to determine which command
has generated a core dump...

Apart from the change to the 'core dump' (etc) output, these
changes are equivalent to the output from (pd)ksh.

Is this all a good idea?

	David

<1> also fixing %+ and %- as job identifiers.

-- 
David Laight: david@l8s.co.uk