Skip to content

Commit

Permalink
Merge pull request #299 from deplinenoise/crashing-tool
Browse files Browse the repository at this point in the history
Report failed/crashing tool command lines
  • Loading branch information
deplinenoise authored Feb 22, 2018
2 parents 9a34783 + 786081d commit 1e127c3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/ExecUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <limits.h>

#include <unistd.h>
#include <sys/stat.h>
Expand All @@ -29,7 +30,7 @@ namespace t2
static void SetFdNonBlocking(int fd)
{
int flags;

flags = fcntl(fd, F_GETFL);
flags |= O_NONBLOCK;
if (-1 == fcntl(fd, F_SETFL, flags))
Expand Down Expand Up @@ -164,7 +165,7 @@ ExecuteProcess(
TerminalIoPrintf(job_id, -199, "%s\n", cmd_line);

/* Sit in a select loop over the two fds */

for (;;)
{
int fd;
Expand Down Expand Up @@ -240,15 +241,23 @@ ExecuteProcess(
close(stderr_pipe[pipe_read]);

TerminalIoJobExit(job_id);

if (WIFSIGNALED(return_code))
{
result.m_ReturnCode = 1;
result.m_WasSignalled = true;

int sig = WTERMSIG(return_code);
TerminalIoPrintf(job_id, INT_MAX, "child process exited on signal %d: %s\n", sig, cmd_line);
}
else
{
result.m_ReturnCode = WEXITSTATUS(return_code);

if (0 != result.m_ReturnCode && !echo_cmdline)
{
TerminalIoPrintf(job_id, INT_MAX, "child process failed with exit code %d: %s\n", result.m_ReturnCode, cmd_line);
}
}

return result;
Expand Down

0 comments on commit 1e127c3

Please sign in to comment.