Path: utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: Killing the correct process Message-ID: <5312@star.cs.vu.nl> Date: 6 Feb 90 14:26:18 GMT References: <22332@adm.BRL.MIL> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Informatika, Amsterdam, the Netherlands Lines: 41 In article <22332@adm.BRL.MIL>, marwood@ncs.dnd.ca (Gordon Marwood) wants to timeout ftp. How about using the following general purpose script? If that's out of the question, the script might still give you a hint how to solve your problem. ----------8<----------8<----------8<----------8<----------8<---------- #!/bin/sh # @(#)timeout 4.1 90/01/10 Maarten Litmaath prog=`basename $0` verbose=0 case $1 in -v) verbose=1 shift esac expr $# \< 2 \| 0"$1" : '.*[^0-9]' > /dev/null && { echo "Usage: $prog [-v] " >&2 exit 2 } timeout=$1 shift exec 3>&1 4>&2 2> /dev/null pid=` sh -c ' (sleep '$timeout' > /dev/null & echo $!; exec >&-; wait; kill -9 $$) & exec "$@" >&3 3>&- 2>&4 4>&- ' $prog "$@" ` kill -9 $pid && exit 0 test $verbose = 1 && echo TIMEOUT >&4 exit 1 -- The meek get the earth, Henry the moon, the rest of us have other plans. | Maarten Litmaath @ VU Amsterdam: maart@cs.vu.nl, uunet!mcsun!botter!maart