Problems with Job Control in csh
    Paul Falstad 
    pfalstad at phoenix.Princeton.EDU
       
    Wed Apr 10 08:44:32 AEST 1991
    
    
  
streeter at theory.lcs.mit.edu (Kenneth B Streeter) wrote:
>I'm having problems with trying to do job control in a csh script.  I
>want to be able to commence a background job (I'm using the &
>metacharacter), use it for some request-handling, and then later kill
>the backgrounded job.
>    xterm -e "<my-executable>" &
>    # <processing deleted>
>    kill %1
You can't refer to process with the "%<number>" construct in
noninteractive shells in csh; you can only do it when job control is in
effect.  Really, this should not require job control to be in effect;
for example, this script will work fine in zsh, and also in itcsh, I
believe.  But if you're using an sh-derived shell (sh,ksh,bash,...) this
will work fine:
xterm -e "foobar" &
# ...
kill -9 $!
I think the only way to do this in csh is to do something like this:
xterm -e "foobar" &
# ...
kill -9 -$$
# end of script
where the "kill" kills off the shell and the xterm by killing the
whole process group.  You're better off not to write the script in csh IMHO.
--
Paul Falstad, pfalstad at phoenix.princeton.edu | 10 PRINT "PRINCETON CS"
[Your blood pressure just went up.]          | 20 GOTO 10
Princeton University would like to apologize to everyone for this article.
    
    
More information about the Comp.unix.shell
mailing list