Title: child_process.spawn sh not killable · Issue #2098 · nodejs/node · GitHub
Open Graph Title: child_process.spawn sh not killable · Issue #2098 · nodejs/node
X Title: child_process.spawn sh not killable · Issue #2098 · nodejs/node
Description: Comming from here: darkguy2008/parallelshell#22 (btw: Usecase for #1009) Everytime I need to spawn a process I do it like this if (process.platform === 'win32') { sh = 'cmd'; shFlag = '/c'; } else { sh = 'sh'; shFlag = '-c'; } var child ...
Open Graph Description: Comming from here: darkguy2008/parallelshell#22 (btw: Usecase for #1009) Everytime I need to spawn a process I do it like this if (process.platform === 'win32') { sh = 'cmd'; shFlag = '/c'; } else ...
X Description: Comming from here: darkguy2008/parallelshell#22 (btw: Usecase for #1009) Everytime I need to spawn a process I do it like this if (process.platform === 'win32') { sh = 'cmd'; shFlag...
Opengraph URL: https://github.com/nodejs/node/issues/2098
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"child_process.spawn sh not killable","articleBody":"Comming from here:\nhttps://github.com/keithamus/parallelshell/issues/22\n\n(btw: Usecase for #1009)\n\nEverytime I need to spawn a process I do it like this\n\n``` js\nif (process.platform === 'win32') {\n sh = 'cmd';\n shFlag = '/c';\n} else {\n sh = 'sh';\n shFlag = '-c';\n}\nvar child = spawn(sh,[shFlag,cmd], {\n cwd: process.cwd,\n env: process.env,\n stdio: ['pipe', process.stdout, process.stderr]\n})\n```\n\nThe problem: `child` is unkillable on unix.\nExample in coffee-script:\n\n``` coffee\nspawn = require(\"child_process\").spawn\nchild = spawn \"sh\", [\"-c\", \"node -e 'setTimeout(function(){},10000);'\"]\nchild.on \"close\", process.exit\nchild.kill()\nchild.kill(\"SIGINT\")\nchild.kill(\"SIGTERM\")\nchild.kill(\"SIGHUP\")\nspawn \"sh\",[\"-c\",\"kill -TERM \"+child.pid]\nspawn \"sh\",[\"-c\",\"kill -INT \"+child.pid]\nspawn \"sh\",[\"-c\",\"kill -HUP \"+child.pid]\n```\n\n(on windows it works fine with sh replaced by cmd)\nEven when I exit the process with `process.exit()`, the child stays alive.\n\nWorkaround I found:\n\n``` coffee\nspawn = require(\"child_process\").spawn\nchild = spawn \"sh\", [\"-c\", \"node -e 'setTimeout(function(){},10000);'\"], detached: true\nchild.on \"close\", process.exit\nspawn \"sh\",[\"-c\",\"kill -INT -\"+child.pid]\n```\n\nKilling by pgid works, by pid works not. Sending ^C from console works also, I assume it uses pgid always.\n","author":{"url":"https://github.com/paulpflug","@type":"Person","name":"paulpflug"},"datePublished":"2015-07-03T10:19:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/2098/node/issues/2098"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4c5b86b7-06cd-6aac-769f-087613a8fb1b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 92F0:ABE86:4D7E4:68754:6A4D7907 |
| html-safe-nonce | 3c795263b801531331117f7c957edf72ad2725831593dd2d74fca80d5be5727f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkYwOkFCRTg2OjREN0U0OjY4NzU0OjZBNEQ3OTA3IiwidmlzaXRvcl9pZCI6IjEyMjk3MDcyODgxOTA0ODI2OTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0919906e24cf923e6eb24f9be25f6231a2fb13ea45c906ba898e03a80b345c8c |
| hovercard-subject-tag | issue:92843674 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/2098/issue_layout |
| twitter:image | https://opengraph.githubassets.com/48c41fb82dc2448162b807d30eaae70c1d5b40afb4aeb4ed3abbde62534cadb3/nodejs/node/issues/2098 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/48c41fb82dc2448162b807d30eaae70c1d5b40afb4aeb4ed3abbde62534cadb3/nodejs/node/issues/2098 |
| og:image:alt | Comming from here: darkguy2008/parallelshell#22 (btw: Usecase for #1009) Everytime I need to spawn a process I do it like this if (process.platform === 'win32') { sh = 'cmd'; shFlag = '/c'; } else ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | paulpflug |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7f8e15305e2ab58890ca84b830615e375f5df303cf471cafcba0c08272981be3 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8608b0750fc35e283e5ec5b094bff942d7a0e197 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width