Repeat of a question posted to net.unix (resp: shell processing)

Phil Pfeiffer pfeiffer at rsch.WISC.EDU
Thu Sep 18 05:03:40 AEST 1986


Thought I'd post this request for info on how background shell jobs,
programs, and stdin/stdout interact on net.unix-wizards, because of the
lack of response from readers of net.unix.


The systems in question are 4.3BSD Unix and Ultrix.
The problem is as follows:


Assume that file "nxf" does not exist.
Assume that the following lines are in shell script 'cmd':
 
  #!/bin/csh
  rm nxf         >& cmd_out
  echo $status   >  cmd_stat


Assume the following lines are in shell script 'master': 

   #!( doesn't matter whether the csi is "/bin/sh" or "/bin/csh" )
   cmd

'master' executes just fine.  The "cannot find file" error message and
error status values are written into cmd_out and cmd_stat, respectively.
(the "cmd_stat" file contains a "1").


However, assume the following lines are in shell script 'bgmaster': 

   #!( doesn't matter whether the csi is "/bin/sh" or "/bin/csh" )
   cmd &
   wait

Now, if 'bgmaster' is executed, "cmd_out" is empty on return, and
"cmd_stat" contains the single line, "0".   Why?

Have I failed to understand something obvious about shell background processing?


-- 
-- Phil Pfeiffer

...!{harvard,ihnp4,seismo,topaz}!uwvax!pfeiffer
(608) 263-7308



More information about the Comp.unix.wizards mailing list