{"id":75,"date":"2010-05-07T11:44:39","date_gmt":"2010-05-07T17:44:39","guid":{"rendered":"http:\/\/zekesdominion.com\/?p=75"},"modified":"2013-08-08T20:37:33","modified_gmt":"2013-08-09T02:37:33","slug":"killing-all-child-processes-in-a-shell-script","status":"publish","type":"post","link":"https:\/\/zekesdominion.com\/?p=75","title":{"rendered":"Killing all child processes in a shell script"},"content":{"rendered":"<p>If you have a shell script that runs a lot of jobs in the background, you will want to clean these processes up at the end of the execution ( say the user hits CTRL-C or kills the job). To do so is fairly easy if you know how to do it. No need to keep track of pids, just do <strong><code>kill 0<\/code><\/strong> as part of the signal trap execution. eg.<br \/>\n<code><br \/>\n#!\/bin\/bash<\/p>\n<p>trap \"kill 0\" SIGINT SIGTERM<\/p>\n<p>runprogram &<br \/>\notherprogram &<\/p>\n<p>wait<br \/>\n<\/code><\/p>\n<p>Found at: <a href=\"http:\/\/stackoverflow.com\/questions\/976059\/shell-script-to-spawn-processes-terminate-children-on-sigterm\">stackoverflow.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have a shell script that runs a lot of jobs in the background, you will want to clean these processes up at the end of the execution ( say the user hits CTRL-C or kills the job). To do so is fairly easy if you know how to do it. No need to [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-tips"],"_links":{"self":[{"href":"https:\/\/zekesdominion.com\/index.php?rest_route=\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zekesdominion.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zekesdominion.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zekesdominion.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/zekesdominion.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=75"}],"version-history":[{"count":8,"href":"https:\/\/zekesdominion.com\/index.php?rest_route=\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/zekesdominion.com\/index.php?rest_route=\/wp\/v2\/posts\/75\/revisions\/115"}],"wp:attachment":[{"href":"https:\/\/zekesdominion.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zekesdominion.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zekesdominion.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}