Skip to content

Commit 5a1578a

Browse files
authored
Use struct info for signal numbers. NFC (#22461)
1 parent c6cabd5 commit 5a1578a

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

src/library.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,15 +364,14 @@ addToLibrary({
364364
var signalToNumber = (sig) => {
365365
// implement only the most common ones, and fallback to SIGINT
366366
switch (sig) {
367-
case 'SIGHUP': return 1;
368-
case 'SIGINT': return 2;
369-
case 'SIGQUIT': return 3;
370-
case 'SIGFPE': return 8;
371-
case 'SIGKILL': return 9;
372-
case 'SIGALRM': return 14;
373-
case 'SIGTERM': return 15;
367+
case 'SIGHUP': return {{{ cDefs.SIGHUP }}};
368+
case 'SIGQUIT': return {{{ cDefs.SIGQUIT }}};
369+
case 'SIGFPE': return {{{ cDefs.SIGFPE }}};
370+
case 'SIGKILL': return {{{ cDefs.SIGKILL }}};
371+
case 'SIGALRM': return {{{ cDefs.SIGALRM }}};
372+
case 'SIGTERM': return {{{ cDefs.SIGTERM }}};
373+
default: return {{{ cDefs.SIGINT }}};
374374
}
375-
return 2; // SIGINT
376375
}
377376
return _W_EXITCODE(0, signalToNumber(ret.signal));
378377
}

src/struct_info.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,13 @@
278278
{
279279
"file": "signal.h",
280280
"defines": [
281-
"SIGALRM"
281+
"SIGALRM",
282+
"SIGFPE",
283+
"SIGHUP",
284+
"SIGINT",
285+
"SIGKILL",
286+
"SIGQUIT",
287+
"SIGTERM"
282288
]
283289
},
284290
{

src/struct_info_generated.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@
371371
"SEEK_SET": 0,
372372
"SIGALRM": 14,
373373
"SIGCANCEL": 33,
374+
"SIGFPE": 8,
375+
"SIGHUP": 1,
376+
"SIGINT": 2,
377+
"SIGKILL": 9,
378+
"SIGQUIT": 3,
379+
"SIGTERM": 15,
374380
"SOCK_CLOEXEC": 524288,
375381
"SOCK_DGRAM": 2,
376382
"SOCK_NONBLOCK": 2048,

src/struct_info_generated_wasm64.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@
371371
"SEEK_SET": 0,
372372
"SIGALRM": 14,
373373
"SIGCANCEL": 33,
374+
"SIGFPE": 8,
375+
"SIGHUP": 1,
376+
"SIGINT": 2,
377+
"SIGKILL": 9,
378+
"SIGQUIT": 3,
379+
"SIGTERM": 15,
374380
"SOCK_CLOEXEC": 524288,
375381
"SOCK_DGRAM": 2,
376382
"SOCK_NONBLOCK": 2048,

0 commit comments

Comments
 (0)