Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit dfee598

Browse files
committed
Replace node::signo_string with local implementation
PR-URL: #101 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 730dfa3 commit dfee598

3 files changed

Lines changed: 133 additions & 8 deletions

File tree

src/module.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static void SignalDumpInterruptCallback(Isolate* isolate, void* data) {
245245
fprintf(stdout, "node-report: SignalDumpInterruptCallback triggering report\n");
246246
}
247247
TriggerNodeReport(isolate, kSignal_JS,
248-
node::signo_string(report_signal), __func__, nullptr, MaybeLocal<Value>());
248+
SignoString(report_signal), __func__, nullptr, MaybeLocal<Value>());
249249
}
250250
report_signal = 0;
251251
}
@@ -260,7 +260,7 @@ static void SignalDumpAsyncCallback(uv_async_t* handle) {
260260
fprintf(stdout, "node-report: SignalDumpAsyncCallback triggering NodeReport\n");
261261
}
262262
TriggerNodeReport(Isolate::GetCurrent(), kSignal_UV,
263-
node::signo_string(report_signal), __func__, nullptr, MaybeLocal<Value>());
263+
SignoString(report_signal), __func__, nullptr, MaybeLocal<Value>());
264264
}
265265
report_signal = 0;
266266
}
@@ -327,7 +327,7 @@ inline void* ReportSignalThreadMain(void* unused) {
327327
for (;;) {
328328
uv_sem_wait(&report_semaphore);
329329
if (nodereport_verbose) {
330-
fprintf(stdout, "node-report: signal %s received\n", node::signo_string(report_signal));
330+
fprintf(stdout, "node-report: signal %s received\n", SignoString(report_signal));
331331
}
332332
uv_mutex_lock(&node_isolate_mutex);
333333
if (auto isolate = node_isolate) {

src/node_report.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void reportEndpoints(uv_handle_t* h, std::ostringstream& out);
7272
void reportPath(uv_handle_t* h, std::ostringstream& out);
7373
void walkHandle(uv_handle_t* h, void* arg);
7474
void WriteInteger(std::ostream& out, size_t value);
75+
const char *SignoString(int signo);
7576

7677
// Global variable declarations - definitions are in src/node-report.c
7778
extern char report_filename[NR_MAXNAME + 1];

src/utilities.cc

Lines changed: 129 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,7 @@ void walkHandle(uv_handle_t* h, void* arg) {
451451
// See http://docs.libuv.org/en/v1.x/signal.html
452452
type = "signal";
453453
data << "signum: " << handle->signal.signum
454-
// node::signo_string() is not exported by Node.js on Windows.
455-
#ifndef _WIN32
456-
<< " (" << node::signo_string(handle->signal.signum) << ")"
457-
#endif
458-
;
454+
<< " (" << SignoString(handle->signal.signum) << ")";
459455
break;
460456
}
461457
case UV_FILE: type = "file"; break;
@@ -550,4 +546,132 @@ void WriteInteger(std::ostream& out, size_t value) {
550546
}
551547
}
552548

549+
/*******************************************************************************
550+
* Utility function to convert a numeric signal number to a string.
551+
*
552+
* This code has been copied from node/src/node.cc function signo_string().
553+
******************************************************************************/
554+
const char *SignoString(int signo) {
555+
#define SIGNO_CASE(e) case e: return #e;
556+
switch (signo) {
557+
#ifdef SIGHUP
558+
SIGNO_CASE(SIGHUP);
559+
#endif
560+
#ifdef SIGINT
561+
SIGNO_CASE(SIGINT);
562+
#endif
563+
#ifdef SIGQUIT
564+
SIGNO_CASE(SIGQUIT);
565+
#endif
566+
#ifdef SIGILL
567+
SIGNO_CASE(SIGILL);
568+
#endif
569+
#ifdef SIGTRAP
570+
SIGNO_CASE(SIGTRAP);
571+
#endif
572+
#ifdef SIGABRT
573+
SIGNO_CASE(SIGABRT);
574+
#endif
575+
#ifdef SIGIOT
576+
# if SIGABRT != SIGIOT
577+
SIGNO_CASE(SIGIOT);
578+
# endif
579+
#endif
580+
#ifdef SIGBUS
581+
SIGNO_CASE(SIGBUS);
582+
#endif
583+
#ifdef SIGFPE
584+
SIGNO_CASE(SIGFPE);
585+
#endif
586+
#ifdef SIGKILL
587+
SIGNO_CASE(SIGKILL);
588+
#endif
589+
#ifdef SIGUSR1
590+
SIGNO_CASE(SIGUSR1);
591+
#endif
592+
#ifdef SIGSEGV
593+
SIGNO_CASE(SIGSEGV);
594+
#endif
595+
#ifdef SIGUSR2
596+
SIGNO_CASE(SIGUSR2);
597+
#endif
598+
#ifdef SIGPIPE
599+
SIGNO_CASE(SIGPIPE);
600+
#endif
601+
#ifdef SIGALRM
602+
SIGNO_CASE(SIGALRM);
603+
#endif
604+
SIGNO_CASE(SIGTERM);
605+
#ifdef SIGCHLD
606+
SIGNO_CASE(SIGCHLD);
607+
#endif
608+
#ifdef SIGSTKFLT
609+
SIGNO_CASE(SIGSTKFLT);
610+
#endif
611+
#ifdef SIGCONT
612+
SIGNO_CASE(SIGCONT);
613+
#endif
614+
#ifdef SIGSTOP
615+
SIGNO_CASE(SIGSTOP);
616+
#endif
617+
#ifdef SIGTSTP
618+
SIGNO_CASE(SIGTSTP);
619+
#endif
620+
#ifdef SIGBREAK
621+
SIGNO_CASE(SIGBREAK);
622+
#endif
623+
#ifdef SIGTTIN
624+
SIGNO_CASE(SIGTTIN);
625+
#endif
626+
#ifdef SIGTTOU
627+
SIGNO_CASE(SIGTTOU);
628+
#endif
629+
#ifdef SIGURG
630+
SIGNO_CASE(SIGURG);
631+
#endif
632+
#ifdef SIGXCPU
633+
SIGNO_CASE(SIGXCPU);
634+
#endif
635+
#ifdef SIGXFSZ
636+
SIGNO_CASE(SIGXFSZ);
637+
#endif
638+
#ifdef SIGVTALRM
639+
SIGNO_CASE(SIGVTALRM);
640+
#endif
641+
#ifdef SIGPROF
642+
SIGNO_CASE(SIGPROF);
643+
#endif
644+
#ifdef SIGWINCH
645+
SIGNO_CASE(SIGWINCH);
646+
#endif
647+
#ifdef SIGIO
648+
SIGNO_CASE(SIGIO);
649+
#endif
650+
#ifdef SIGPOLL
651+
#if SIGPOLL != SIGIO
652+
SIGNO_CASE(SIGPOLL);
653+
#endif
654+
#endif
655+
#ifdef SIGLOST
656+
#if SIGLOST != SIGABRT
657+
SIGNO_CASE(SIGLOST);
658+
#endif
659+
#endif
660+
#ifdef SIGPWR
661+
#if SIGPWR != SIGLOST
662+
SIGNO_CASE(SIGPWR);
663+
#endif
664+
#endif
665+
#ifdef SIGINFO
666+
#if !defined(SIGPWR) || SIGINFO != SIGPWR
667+
SIGNO_CASE(SIGINFO);
668+
#endif
669+
#endif
670+
#ifdef SIGSYS
671+
SIGNO_CASE(SIGSYS);
672+
#endif
673+
default: return "unknown";
674+
}
675+
}
676+
553677
} // namespace nodereport

0 commit comments

Comments
 (0)