Path: utzoo!attcan!uunet!vsedev!logan From: logan@vsedev.VSE.COM (James Logan III) Newsgroups: comp.unix.questions Subject: Re: Subprocess lives on.......... Keywords: Bourne shell loop Message-ID: <1237@vsedev.VSE.COM> Date: 15 Nov 88 16:33:43 GMT References: <167@heart-of-gold> Reply-To: logan@vsedev.VSE.COM (James Logan III) Organization: VSE Software Development Lab Lines: 40 In article <167@heart-of-gold> jc@heart-of-gold (John M Chambers) writes: >Can anyone figure out how to make the while-loop exit when graf terminates >and the script exits? I've tried playing arount with $? and traps, but I >clearly don't know what I'm doing. I even tried a "kill -HUP 0", and it >worked. But all my windows also exited and I got a login prompt. Sorta >overkill, if you ask me. The shell really should exit without leaving the while loop running (at least under Sys V) because the while loop will be writing on a pipe with no one to read it. This SHOULD cause a SIGPIPE signal to kill the subshell that's running the while loop. Even if the subshell was ignoring the SIGPIPE signal, I can't see how it would start writing to your terminal! My first guess at a fix is this: #!/bin/sh # GrafRoute host # This generates a graph of the "netstat -r" Use data for host, # which may be the destination or the gateway. # ( trap "exit 0" 1 13 15; while true; do netstat -r | grep $1 | cut -c49-59; sleep 6; done; ) | graf -PD +H +V -a -T'Route "'$1'" packet rate'; I don't know what SunView does to terminate the process. Maybe it sends a SIGHUP or a SIGTERM? Anyway, this script will exit when it receives either signal. (Theoretically!) -Jim -- Jim Logan logan@vsedev.vse.com (703) 892-0002 uucp: ..!uunet!vsedev!logan inet: logan%vsedev.vse.com@uunet.uu.net