From 31ed5dc6b1a23f645fd9cc14c0df1642471d1aa2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 9 Jun 2014 02:08:50 +0200 Subject: put process names in quotes and print exit status and termination signal on crashed processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-respawn.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mds-respawn.c b/src/mds-respawn.c index 84c4b26..23c07e6 100644 --- a/src/mds-respawn.c +++ b/src/mds-respawn.c @@ -419,7 +419,7 @@ static void joined_with_server(pid_t pid, int status) if (states[i].state == CREMATED) { - eprintf("cremated child process %s exited, ignoring.", commands[i][0]); + eprintf("cremated child process `%s' exited, ignoring.", commands[i][0]); return; } @@ -430,27 +430,32 @@ static void joined_with_server(pid_t pid, int status) if (WIFEXITED(status) ? (WEXITSTATUS(status) == 0) : ((WTERMSIG(status) == SIGTERM) || (WTERMSIG(status) == SIGINT))) { - eprintf("child process %s exited normally, cremating.", commands[i][0]); + eprintf("child process `%s' exited normally, cremating.", commands[i][0]); states[i].state = CREMATED; return; } + if (WIFEXITED(status)) + eprintf("`%s' exited with code %i.", commands[i][0], WEXITSTATUS(status)); + else + eprintf("`%s' died by signal %i.", commands[i][0], WTERMSIG(status)); + if (monotone(&ended) < 0) { perror(*argv); - eprintf("%s died abnormally, burying because we could not read the time.", commands[i][0]); + eprintf("`%s' died abnormally, burying because we could not read the time.", commands[i][0]); states[i].state = DEAD_AND_BURIED; return; } if (ended.tv_sec - states[i].started.tv_sec < interval) { - eprintf("%s died abnormally, burying because it died too fast.", commands[i][0]); + eprintf("`%s' died abnormally, burying because it died too fast.", commands[i][0]); states[i].state = DEAD_AND_BURIED; return; } - eprintf("%s died abnormally, respawning.", commands[i][0]); + eprintf("`%s' died abnormally, respawning.", commands[i][0]); spawn_server(i); } -- cgit v1.2.3-70-g09d2