From b471f2db6e79abeda1717f3f136bc369eb916958 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sat, 9 Apr 2011 19:51:21 +0200 Subject: Prefix perror(3) messages with program name. It make it easier while debugging to know who is reporting the error: Ninja itself or one of the command called by Ninja during the build process or one of the generator which called Ninja. --- src/browse.cc | 10 +++++----- src/ninja.cc | 2 +- src/parsers.cc | 2 +- src/subprocess.cc | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/browse.cc b/src/browse.cc index db89db0..f65e537 100644 --- a/src/browse.cc +++ b/src/browse.cc @@ -25,13 +25,13 @@ void RunBrowsePython(State* state, const char* ninja_command) { // (Actually the Python process becomes the parent.) int pipefd[2]; if (pipe(pipefd) < 0) { - perror("pipe"); + perror("ninja: pipe"); return; } pid_t pid = fork(); if (pid < 0) { - perror("fork"); + perror("ninja: fork"); return; } @@ -39,7 +39,7 @@ void RunBrowsePython(State* state, const char* ninja_command) { close(pipefd[1]); do { if (dup2(pipefd[0], 0) < 0) { - perror("dup2"); + perror("ninja: dup2"); break; } @@ -48,7 +48,7 @@ void RunBrowsePython(State* state, const char* ninja_command) { "python", "-", ninja_command, NULL }; execvp(command[0], (char**)command); - perror("execvp"); + perror("ninja: execvp"); } while (false); _exit(1); } else { // Child. @@ -57,7 +57,7 @@ void RunBrowsePython(State* state, const char* ninja_command) { // Write the script file into the stdin of the Python process. ssize_t len = write(pipefd[1], kBrowsePy, sizeof(kBrowsePy)); if (len < (ssize_t)sizeof(kBrowsePy)) - perror("write"); + perror("ninja: write"); close(pipefd[1]); exit(0); } diff --git a/src/ninja.cc b/src/ninja.cc index 5e26f6a..cd64c84 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -186,7 +186,7 @@ int main(int argc, char** argv) { char cwd[PATH_MAX]; if (!getcwd(cwd, sizeof(cwd))) { - perror("getcwd"); + perror("ninja: getcwd"); return 1; } diff --git a/src/parsers.cc b/src/parsers.cc index b9c1190..4aeb73c 100644 --- a/src/parsers.cc +++ b/src/parsers.cc @@ -291,7 +291,7 @@ bool ManifestParser::Parse(const string& input, string* err) { // XXX remove this hack, or make it more principled. char cwd[1024]; if (!getcwd(cwd, sizeof(cwd))) { - perror("getcwd"); + perror("ninja: getcwd"); return 1; } value = cwd + value.substr(9); diff --git a/src/subprocess.cc b/src/subprocess.cc index 1043e65..cef0ad3 100644 --- a/src/subprocess.cc +++ b/src/subprocess.cc @@ -157,7 +157,7 @@ void SubprocessSet::DoWork() { int ret = poll(fds.data(), fds.size(), -1); if (ret == -1) { if (errno != EINTR) - perror("poll"); + perror("ninja: poll"); return; } -- cgit v0.12