shell - How can I stop a background-process started from bash after the next command finished? -


how manage, morbo-server called here background-process shutdown/killed automatically if close firefox-window or if stop script in way?

#!/bin/bash  morbo mojolicious_lite.pl &  firefox -new-window http://localhost:3000/ 

ok, let's solve one.

#!/bin/bash morbo mojolicious_lite.pl & p=$! trap "kill $p" int # maybe want exit here too? firefox -new-window http://localhost:3000/ wait 

this 1 should work... when firefox exits shell wait remaining jobs (morbo) can interrupted ctrl-c - in case trap kills them.

you can test visually (i.e. seeing gets executed) with

bash -x run.sh 

assuming script called run.sh ;)


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -