Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Spawning Child Processes Causes "Error: uv_signal_start EINVAL" Exception for 0.10.20 or 0.11.8-pre in AMD64 Linux Environment. #6339

Closed
x684867 opened this issue Oct 12, 2013 · 10 comments

Comments

@x684867
Copy link

x684867 commented Oct 12, 2013

(1) A node application written under 0.8 an 0.9 was able to spawn child processes without problems.
(2) On 11 Oct 2013, node was upgraded to 0.10.20 and the application began to crash each time processes were spawned or each time process.on() was called.
(3) Further investigation pulled down the latest code for 0.11.8-pre and reproduced the issue.
(4) The following EXCEPTION output was encountered:


app.main[2013-10-12T01:36:35.928Z] app.js PID:[2939]

app.main[2013-10-12T01:36:35.929Z] Setup Process Management

node.js:612
throw errnoException(err, 'uv_signal_start');
^
Error: uv_signal_start EINVAL
at exports._errnoException (util.js:676:11)
at process.on.process.addListener (node.js:612:17)
at Object. (/srv/nemesis/app/app.js:60:9)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Function.Module.runMain (module.js:490:10)
at startup (node.js:121:16)
at node.js:764:3
done.

NODE VERSION: v0.11.8-pre

(5) The following EXCEPTION output was encountered elsewhere in the app:

lib.worker[2013-10-12T01:04:28.143Z] worker.js is starting...

node.js:762
throw errnoException(process._errno, 'uv_signal_start');
^
Error: uv_signal_start EINVAL
at errnoException (node.js:540:13)
at process.on.process.addListener (node.js:762:17)
at Object. (/srv/nemesis/app/library/worker.js:78:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3

@bnoordhuis
Copy link
Member

That very likely means you're trying to install a signal handler for SIGKILL or SIGSTOP.

In old versions of node that was allowed in the sense that node didn't check the return value of sigaction(). Of course, it didn't work - you can't catch those signals. In newer versions you get an EINVAL error.

Closing, working as expected.

@tomerb15
Copy link

tomerb15 commented May 10, 2016

How can i debug my graceful shutdown code, it seems to be impossible no matter which IDE i use since none of them shuts down the debug sessions with something else other than SIGKILL SIGINT SIGTERM

@bnoordhuis
Copy link
Member

There is no solution, you can't catch SIGKILL.

@tomerb15
Copy link

Its not about catching it, its about being able to debug the graceful shutdown code

@bnoordhuis
Copy link
Member

Then you should rephrase your question because I don't understand what you're getting at.

@tomerb15
Copy link

Its now updated, hopefully its more clear now

@eljefedelrodeodeljefe
Copy link

eljefedelrodeodeljefe commented May 10, 2016

Can you add some sample code, which is at best self contained?

@bnoordhuis
Copy link
Member

@tomerb15 You can install event handlers for SIGINT and SIGTERM. If your IDE sends SIGKILL however, you're out of luck.

@tomerb15
Copy link

@eljefedelrodeodeljefe here is the code from my app.js:

// GRACEFULL SHUTDOWN
process.stdin.resume();//so the program will not close instantly

//do something when app is closing
process.on('exit', generalUtil.exitHandler.bind(null,{exit:true,event: "exit"}));

//catches ctrl+c event
process.on('SIGINT', generalUtil.exitHandler.bind(null, {exit:true,event: "SIGINT"}));
process.on('SIGTERM', generalUtil.exitHandler.bind(null, {exit:true,event: "SIGTERM"}));

//catches uncaught exceptions
process.on('uncaughtException', generalUtil.exitHandler.bind(null, {exit:false,event: "uncaughtException"}));

The challenge is to be able to debug generalUtil.exitHandler

@MaerF0x0
Copy link

MaerF0x0 commented Aug 5, 2016

Google brought me here years later, this is worth reading. https://nodejs.org/api/process.html#process_signal_events

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

No branches or pull requests

5 participants