From: Ben Pfaff Date: Wed, 21 Jan 2009 00:28:38 +0000 (-0800) Subject: Improve handling of unexpected 'status' in process_status_msg(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=633aaefd48bedd45811ac36793669a5fad378d24;p=openvswitch Improve handling of unexpected 'status' in process_status_msg(). This function was getting passed -1 as 'status' due to a bug elsewhere, and it was outputting ", core dumped" as the result, which clearly isn't very helpful. This improves the situation. --- diff --git a/lib/process.c b/lib/process.c index c3e3de5c..a06f5dc1 100644 --- a/lib/process.c +++ b/lib/process.c @@ -313,15 +313,19 @@ process_status_msg(int status) struct ds ds = DS_EMPTY_INITIALIZER; if (WIFEXITED(status)) { ds_put_format(&ds, "exit status %d", WEXITSTATUS(status)); - } else if (WIFSIGNALED(status)) { + } else if (WIFSIGNALED(status) || WIFSTOPPED(status)) { + int signr = WIFSIGNALED(status) ? WTERMSIG(status) : WSTOPSIG(status); const char *name = NULL; #ifdef HAVE_STRSIGNAL - name = strsignal(WTERMSIG(status)); + name = strsignal(signr); #endif - ds_put_format(&ds, "killed by signal %d", WTERMSIG(status)); + ds_put_format(&ds, "%s by signal %d", + WIFSIGNALED(status) ? "killed" : "stopped", signr); if (name) { ds_put_format(&ds, " (%s)", name); } + } else { + ds_put_format(&ds, "terminated abnormally (%x)", status); } if (WCOREDUMP(status)) { ds_put_cstr(&ds, ", core dumped");