weixin_39815310
weixin_39815310
2020-12-02 08:15

Error: Unknown signal: 143

Hey there!

Go this error:

 bash
→ ./cmd.js examples/rest-api/index.js 
Caught SIGINT, generating flamegraph /home/alessio/www/test/0x/index.js:188
      throw e
      ^

Error: Unknown signal: 143
    at process.ChildProcess.kill (internal/child_process.js:361:11)
    at emitOne (events.js:83:20)
    at process.emit (events.js:170:7)
    at process.exit (node.js:763:17)
    at ChildProcess.<anonymous> (/home/alessio/www/test/0x/index.js:169:15)
    at emitTwo (events.js:88:13)
    at ChildProcess.emit (events.js:173:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:201:12)
</anonymous>

So 143 corresponds to SIGTERM, which is sent upon killing the process. So doesn't that mean that this line should check for codes 0 as well as 143? If done so, everything works fine on my system. The generated flamegraph is totally fine.

该提问来源于开源项目:davidmarkclements/0x

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

10条回答

  • weixin_39622084 weixin_39622084 5月前

    Sounds good - but just so I can understand - what circumstances are causing the sigterm? Are you sending a kill signal to your process? What OS, and which node version?

    点赞 评论 复制链接分享
  • weixin_39815310 weixin_39815310 5月前
    
     alessio: /home/alessio/www/test/0x git:master
    → uname -a
    Linux DXBU-JKSDJ32 3.19.0-15-generic #15-Ubuntu SMP Thu Apr 16 23:32:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    
     alessio: /home/alessio/www/test/0x git:master
    → node -v && npm -v
    v5.2.0
    3.3.12
    

    I'm just doing CTRL+C in order to generate my flamegraph, and I assume 0x is killing the perf process?

    点赞 评论 复制链接分享
  • weixin_39622084 weixin_39622084 5月前

    Ahhhh okay yes I see

    So on os x the node process and the tracer both started by 0x - we send a sigint to the node process itself and it exits with a code 0

    On Linux, perf has to start the node process (if you attach later it fails to get js stacks :() - so we send a SIGINT to perf which sends a SIGTERM to your nose process which seems to result in 143.

    Interestengly it resulted in a 0 (and possibly a SIGINT) on an Ubuntu ami so possibly the version of perf affects how it kills the child (maybe later versions pass the signal through to the child).

    Really what I'd like is for the node process to get the sigint so it's consistent with os x and expected behaviour (eg if I press ctrl c I expect to get a sigint not a sigterm)

    What I might have to do is find the pid of the node child process started by perf and send the sigint to that.

    点赞 评论 复制链接分享
  • weixin_39815310 weixin_39815310 5月前

    What I might have to do is find the pid of the node child process started by perf and send the sigint to that.

    Ah I understand. I'll try to have a go at that myself, see if I can make it work as you wanted.

    点赞 评论 复制链接分享
  • weixin_39815310 weixin_39815310 5月前

    I've made a pull request that applies a bandaid (checks for code 143) until we can close this as you've stated. I might have an idea on how to fix it like you said though, will do some testing now.

    点赞 评论 复制链接分享
  • weixin_39815310 weixin_39815310 5月前

    I've tried to play with ps-tree and get the node process pid to close that before closing the master (perf process), but it seems that when I try to list the children inside process.once('SIGINT', ... the node process isn't included anymore, it gets shutdown by default somehow on SIGINT. Have I missed something?

    点赞 评论 复制链接分享
  • weixin_39815310 weixin_39815310 5月前

    I have discovered another issue with the exit codes. Not sure exactly why that is happening, but I'm also getting 130 sometimes (corresponds to SIGINT from what I've searched) as an exit code.

    点赞 评论 复制链接分享
  • weixin_39622084 weixin_39622084 5月前

    Ho hum - lets do this - can you modify the PR to allow for 130 as well and I'll release that today - need to think about it a bit more

    点赞 评论 复制链接分享
  • weixin_39815310 weixin_39815310 5月前

    did that! btw, I hope I don't bother you with so many issues / replies. I'm just super excited by the module and want to help out as I can!

    点赞 评论 复制链接分享
  • weixin_39622084 weixin_39622084 5月前

    bother me as much as you like, I'm as excited as you are (pr merged)

    点赞 评论 复制链接分享