Skip to content

'yarn run' does not forward SIGTERM to process #3424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
frank-weindel opened this issue May 16, 2017 · 6 comments · Fixed by #3789
Closed

'yarn run' does not forward SIGTERM to process #3424

frank-weindel opened this issue May 16, 2017 · 6 comments · Fixed by #3789

Comments

@frank-weindel
Copy link

When running an application via 'yarn run' and a SIGTERM is signaled on it, yarn does not forward the SIGTERM to its child process(es). Hence an application's graceful shutdown code cannot run.

@bestander
Copy link
Member

Send a PR :)

@GAumala
Copy link
Contributor

GAumala commented Jun 4, 2017

Does yarn even handle SIGTERM? if so, where? It would have to keep a reference to every child process and call child.kill() on every one of them when SIGTERM is received.

@bestander
Copy link
Member

@GAumala
Copy link
Contributor

GAumala commented Jun 8, 2017

I'd love to give it a shot, but I have some questions.

So execCommand is in execute-lifecycle-script.js, and then that function eventually calls spawn() in child.js, which uses Node's API for spawning child processes. A reference to the child process is needed to call kill(), but spawn() only returns the process STDOUT. So there are two options:

  • Make spawn() return a reference to the child process instead of STDOUT. The child process object is then passed to whatever signal handler yarn has.
  • Make spawn() attach a SIGTERM listener to the global process object in which child.kill() is executed. If yarn already handles SIGTERM somewhere else, that behavior will be overriden.

Does yarn already have a SIGTERM handler? Which choice should I use?

@OmgImAlexis
Copy link

@frank-weindel can you update the OP as this is an issue with yarn x as well as yarn run x.

@bestander
Copy link
Member

@GAumala, sorry for a delay.

I don't think yarn has a SIGTERM handler except for onDeath() callback when Yarn is executed in mutex mode https://github.com/yarnpkg/yarn/blob/master/src/cli/index.js#L232.

I think returning reference should be a cleaner solution rather than attaching to global process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants