J'ai un script Ruby qui démarre un sous-processus. Je veux qu'ils soient tués quand le processus global est tué.Avoir une commande IO.popen être tué lorsque le processus appelant est tué
IO.popen('testacular start unit.conf.js', 'w')
Exécuter mon script:
user.name:/my/repo [git: my-branch] $ ruby my-script.rb
Sortie de testacular:
user.name:/my/repo [git: my-branch] $ info: Testacular server started at http://localhost:8000/
info (launcher): Starting browser PhantomJS
info (PhantomJS 1.7): Connected on socket id uVAO41Q2niyLA8AqbZ8w
PhantomJS 1.7: Executed 44 of 44 SUCCESS (0.213 secs/0.115 secs)
Hit Control-C pour tuer le processus. Vérifiez les processus en cours:
user.name:/my/repo [git: my-branch] $ ps
PID TTY TIME CMD
# ...
39639 ttys019 0:01.28 node /usr/local/bin/testacular start unit.conf.js
39649 ttys019 0:00.09 node /usr/local/bin/phantomjs /var/folders/2p/dklw3xys2n3f4hqmx73zvz6w0000gp/T/testacular-61981618/capture.js
39650 ttys019 0:00.82 /usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs /var/folders/2p/dklw3xys2n3f4hqmx73zvz6w0000gp/T/testacular-61981618/capture.js
Nous pouvons voir que le processus testacular est toujours en cours d'exécution.
Tuez-le manuellement et voir la sortie d'arrêt testacular typique:
user.name:/my/repo [git: my-branch] $ kill 39639
info: Disconnecting all browsers
error (launcher): Cannot start PhantomJS
user.name:/my/repo [git: my-branch] $
Y at-il un moyen de faire l'appel IO.popen
tel que je ne dois pas tuer manuellement testacular
plus tard?
Génial, merci! –