🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Ray Nickson Wed, 06 Sep 1989 23:39
what is a job?
#580
Author: Ray Nickson
Date: Wed, 06 Sep 1989 23:39
69 lines
2564 bytes
Bash version 1.03, on an HP300 running More/BSD, GCC-compiled.

Have you looked at my (cat /etc/passwd) | cat bug at all?

It seems to me that this problem is related to the shell's decision to
put each side of the pipe in (foo)|(bar) into a separate job:

bash-1.03$ (sleep 100) | (sleep 200)
^Z
[1]+  Stopped             ( sleep 100 )
^Z
[2]+  Stopped             ( sleep 200 )
bash-1.03$ jobs
[1]-  Stopped             ( sleep 100 )
[2]+  Stopped             ( sleep 200 )
bash-1.03$ 

Furthermore, the subshells get stopped, but the commands in them do not:
bash-1.03$ jobs
[1]-  Stopped             ( sleep 100 )
[2]+  Stopped             ( sleep 200 )
bash-1.03$ ps
  PID TT STAT  TIME COMMAND
 1932 p0 I     0:04 bash       <- my parent shell (still 1.02!)
 3003 p0 S     0:03 bash-1.03  <- the shell with the 'bash-1.03$ ' prompt
 3014 p0 T     0:00 bash-1.03  }
 3015 p0 S     0:00 sleep 100  } the subshells and the commands
 3016 p0 T     0:00 bash-1.03  }
 3017 p0 S     0:00 sleep 200  }
 3020 p0 R     0:00 ps
bash-1.03$ 

(the STAT column of our ps has T=stopped, S=short-term sleep,
 I=long-term sleep, R=run).

I don't know who defines what a job really is (Posix?), but this does
not appear to be the way ksh does it, and is certainly not the way csh
does it.  Is it a bug or a feature?

(ksh version ??? on an HP300 running HPUX6.5):
ksh$ (sleep 100)|(sleep 200)
[1] + Stopped                  (sleep 100)|(sleep 200)
ksh$ jobs
[1] + Stopped                  (sleep 100)|(sleep 200)
ksh$ 

(csh version ??? on an HP300 running More/BSD):
csh% (sleep 100)|(sleep 200)
^Z
Stopped
csh% jobs
[1]  + Stopped              ( sleep 100 ) | ( sleep 200 )
csh% ps
  PID TT STAT  TIME COMMAND
 1932 p0 IW    0:06 bash
 3085 p0 S     0:00 -sh (csh)
 3096 p0 T     0:00 sleep 100
 3097 p0 T     0:00 sleep 200
 3098 p0 R     0:00 ps
csh% kill 3096
csh% jobs
[1]  + Terminated           ( sleep 100 ) |
       Stopped              ( sleep 200 )
csh% 

-rgn
--
Ray Nickson, Dept. Comp. Sci., Victoria University of Wellington, New Zealand.
nickson@comp.vuw.ac.nz       ...!uunet!vuwcomp!nickson      + 64 4 721000x8593
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads