Skip to content

Commit 432c513

Browse files
TheSpydercristianoc
authored andcommitted
Always monitor for exit signals, not just in watch mode. Fixes rescript-lang#5590.
1 parent 8dc8f55 commit 432c513

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

rescript

+22-21
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,28 @@ function acquireBuild() {
215215
}
216216
}
217217

218+
219+
function onUncaughtException(err) {
220+
console.error("Uncaught Exception", err);
221+
releaseBuild();
222+
process.exit(1);
223+
}
224+
function exitProcess() {
225+
releaseBuild();
226+
process.exit(0);
227+
}
228+
229+
process.on("uncaughtException", onUncaughtException);
230+
231+
// OS signal handlers
232+
// Ctrl+C
233+
process.on("SIGINT", exitProcess);
234+
// kill pid
235+
process.on("SIGUSR1", exitProcess);
236+
process.on("SIGUSR2", exitProcess);
237+
process.on("SIGTERM", exitProcess);
238+
process.on("SIGHUP", exitProcess);
239+
218240
if (
219241
maybe_subcommand !== undefined &&
220242
maybe_subcommand !== "build" &&
@@ -337,27 +359,6 @@ if (
337359
*/
338360
var watchers = [];
339361

340-
function onUncaughtException(err) {
341-
console.error("Uncaught Exception", err);
342-
releaseBuild();
343-
process.exit(1);
344-
}
345-
function exitProcess() {
346-
releaseBuild();
347-
process.exit(0);
348-
}
349-
350-
process.on("uncaughtException", onUncaughtException);
351-
352-
// OS signal handlers
353-
// Ctrl+C
354-
process.on("SIGINT", exitProcess);
355-
// kill pid
356-
process.on("SIGUSR1", exitProcess);
357-
process.on("SIGUSR2", exitProcess);
358-
process.on("SIGTERM", exitProcess);
359-
process.on("SIGHUP", exitProcess);
360-
361362
process.stdin.on("close", exitProcess);
362363
// close when stdin stops
363364
if (os.platform() !== "win32") {

0 commit comments

Comments
 (0)