shadow-cljs does not die with parent process

Created on 30 Jan 2018  路  4Comments  路  Source: thheller/shadow-cljs

I'm trying to manage some of build tasks in a Node.js tool. As a result, shadow-cljs lives as a child process in my program, which looks like:

 | |-+= 06446 chen /Applications/iTerm.app/Contents/MacOS/iTerm2 --server /usr/bin/login -fqpl chen /Applications/iTerm.app/Contents/MacOS/iTerm2 --launch_shell
 | | \-+= 06447 root /usr/bin/login -fqpl chen /Applications/iTerm.app/Contents/MacOS/iTerm2 --launch_shell
 | |   \-+= 06448 chen -bash
 | |     \-+= 24048 chen node target/main.js
 | |       |-+- 24093 chen node /usr/local/Cellar/yarn/1.3.2/libexec/bin/yarn.js dev
 | |       | \--- 24094 chen node /Users/chen/work/trace-web/node_modules/.bin/webpack-dev-server --hot --hot-only
 | |       \-+- 31073 chen node ./node_modules/.bin/shadow-cljs watch browser
 | |         \--- 31074 chen /usr/bin/java -Djava.util.logging.config.file=target/shadow-cljs/logging.properties -cp src:/Users/chen/.m2/repository/com/cognitect/transit-clj/0.8.300/transit-clj-0.8.300.jar:/Users/chen/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar:/Users/chen/.m2/reposit

I can get 31073(PID) in my program and kill it. After that, I found 31074 turned into an orphan process under 00001. Can we make it die as its parent dies?

Most helpful comment

The problem appears to be child_process.spawnSync. Using cp.spawn combined with an exit handler killing the process seems to work.

One more reason to restructure everything to full async but thats going to take a while.

All 4 comments

The problem appears to be child_process.spawnSync. Using cp.spawn combined with an exit handler killing the process seems to work.

One more reason to restructure everything to full async but thats going to take a while.

Related to this ticket as discussed on Slack, it would make sense to catch the SIGUP/SIGTERM signals and kill Java before calling process.exit(0). Within Emacs I end up with Java zombie processes which may be related to this.

Cool.

I'm still wondering if the problem is remaining. I tried in my app:

proc = child_process.exec("yarn watch", {});
// "yarn watch" for "shadow-cljs watch client"

// running
proc.kill()
// or
proc.kill("SIGINT")

After killing the process, it's supposed exit. But turned out it's still running.

Not sure what's the problem. But is there any misunderstanding on my side?


Tried and it appears to be working with:

node ./node_modules/.bin/shadow-cljs watch client server

So probably yarn scripts has some problem responding to SIGINT events.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

loganpowell picture loganpowell  路  9Comments

dhleong picture dhleong  路  10Comments

jiyinyiyong picture jiyinyiyong  路  4Comments

jinwei233 picture jinwei233  路  8Comments

darwin picture darwin  路  6Comments