Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Show error message of Signal Events unsupported on Windows #2904

Closed
wants to merge 2 commits into from

5 participants

@shigeki
Collaborator

As discussed #1553, signal events are not yet supported on Windows.
The current error message of

process.on('SIGINT', function() {});

is shown on Windows as

C:\Users\ohtsu\Desktop\node\node>Release\node.exe test.js

node.js:197
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: No such module
    at EventEmitter.<anonymous> (node.js:388:27)
    at Object.<anonymous> (C:\Users\ohtsu\Desktop\node\node\test.js:1:71)
    at Module._compile (module.js:443:26)
    at Object..js (module.js:461:10)
    at Module.load (module.js:350:32)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:481:10)
    at EventEmitter._tickCallback (node.js:188:41)

The error description of "No such module" is too ambiguous for users.
This patch shows it more clearly as

C:\Users\ohtsu\Desktop\shigeki>Release\node.exe test.js

node.js:197
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Signal Event: SIGINT is not yet supported on Windows.
    at EventEmitter.<anonymous> (node.js:388:17)
    at Object.<anonymous> (C:\Users\ohtsu\Desktop\shigeki\test.js:1:71)
    at Module._compile (module.js:443:26)
    at Object..js (module.js:461:10)
    at Module.load (module.js:350:32)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:481:10)
    at EventEmitter._tickCallback (node.js:188:41)

I also add notes on doc that signal events are not yet supported on Windows.

doc/api/process.markdown
@@ -55,6 +55,7 @@ stay running forever, `uncaughtException` can be a useful safety mechanism.
Emitted when the processes receives a signal. See sigaction(2) for a list of
standard POSIX signal names such as SIGINT, SIGUSR1, etc.
+Signal Events are not yet supported on Windows.

Should probably bold it to grab more attention. Had to put a couple of notes like this in readline's docs.

@shigeki Collaborator
shigeki added a note

Thanks for the comment. I change the doc description into the same as that in readline. I think that there's no actual workaround on this for simulating this with key events through stdin depends on the key assignments by user, so I did not add the additional notes on it.

If your program uses readline, you can always bind to readline.on('SIGINT', ...). Readline picks up ^C through stdin keypresses.

@shigeki Collaborator
shigeki added a note

I'm using the keypress event of Ctrl-c in stdin direcly. I agree that readline is the alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@domenic

+1, I believe this cryptic error message is what is preventing me from running the npm-www site on Windows.

@domenic domenic referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@domenic domenic referenced this pull request in isaacs/cluster-master
Closed

Wrap SIGHUP/SIGINT/SIGKILL listening in try/catch #1

@isaacs isaacs referenced this pull request from a commit in isaacs/cluster-master
@domenic domenic Wrap SIGHUP/SIGINT/SIGKILL listening in try/catch
Now the module can at least bootstrap itself without crashing on Windows.

Related: joyent/node#2904
3b8a0ab
@Nodejs-Jenkins
Collaborator

Can one of the admins verify this patch?

@domenic

Was this fixed with a test?

@chrisdickinson

@domenic This was closed because node supports SIGINT & SIGHUP, as tested locally on windows xp with node v0.10.30. The docs also reflect this change as of 155df9c. All platforms throw an error when listening for SIGKILL. I did not track down the changeset that changed the behavior on Windows, though -- I can if you'd like!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  doc/api/process.markdown
@@ -53,6 +53,8 @@ stay running forever, `uncaughtException` can be a useful safety mechanism.
<!--type=event-->
<!--name=SIGINT, SIGUSR1, etc.-->
+**This does not work on Windows.**
+
Emitted when the processes receives a signal. See sigaction(2) for a list of
standard POSIX signal names such as SIGINT, SIGUSR1, etc.
View
4 src/node.js
@@ -384,6 +384,10 @@
process.on = process.addListener = function(type, listener) {
var ret = addListener.apply(this, arguments);
if (isSignal(type)) {
+ if (process.platform === 'win32') {
+ throw new Error('Signal Event: ' + type + ' is not yet supported on Windows.');
+ }
+
if (!signalWatchers.hasOwnProperty(type)) {
var b = process.binding('signal_watcher');
var w = new b.SignalWatcher(startup.lazyConstants()[type]);
View
20 test/simple/test-signal-handler.js
@@ -18,18 +18,26 @@
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
+var common = require('../common');
+var assert = require('assert');
+console.log('process.pid: ' + process.pid);
-// SIGUSR1 and SIGHUP are not supported on Windows
+// SIGINT is not yet supported on Windows.
if (process.platform === 'win32') {
+ var errmsg = 'Signal Event: SIGINT is not yet supported on Windows.';
+ assert.throws(function() {
+ process.on('SIGINT', function() {});
+ }, function(err) {
+ if (err instanceof Error) {
+ assert.strictEqual(err.message, errmsg);
+ return true;
+ }
+ });
+ // Rest of tests are not supported on Windows.
process.exit(0);
}
-var common = require('../common');
-var assert = require('assert');
-
-console.log('process.pid: ' + process.pid);
-
var first = 0,
second = 0;
Something went wrong with that request. Please try again.