On Sat, 2002-11-09 at 19:09, Jesse Kline wrote:
> I've made a very simple bash script to run setiathome and xsetiathome.
> The script looks like this:
> #!/bin/sh
> ~/setiathome/setiathome -graphics &
> ~/setiathome/xsetiathome
> exit 0
> My question is, since I made the setiathome process into a background
> process, how can I get it to terminate when I terminate the script (done
> by hitting Control-C at the command line)?
>
> Thank you,
>
> Jesse
>
>
This should work:
#!/bin/sh
trap "finish" 2 # trap ctrl-c
finish()
{
kill $PID
}
~/setiathome/setiathome -graphics &
PID=$!
~/setiathome/xsetiathome
exit 0