starr@tybalt.caltech.edu (Christopher H. Starr) (03/24/90)
hitz@auspex.auspex.com (Dave Hitz) writes: >In a shell script I want to start a process in the background and then >kill it at some later time. To do this I want to save its pid in a >variable. > [... stuff deleted ...] >Anyone have a [clean] way to do this? >Dave Hitz home: 408-739-7116 >UUCP: {uunet,mips,sun,bridge2}!auspex!hitz work: 408-492-0900 Why not use the shell variable '$!' which is defined as the process number of the last process run in the background (in decimal)? In your script (which I assume is a Bourne shell script), you can have, for example, ______________________ a.out & PID=$! : ' ... do stuff ... ' kill $PID ______________________ I hope this helps. - Christopher Starr ( starr@tybalt.caltech.edu )