diff options
author | Nico Weber <thakis@chromium.org> | 2020-07-02 13:49:04 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-02 20:34:06 +0200 |
commit | 526ca6878629865a1f535552abbfcd17d7e04326 (patch) | |
tree | 83c81dd3bbf7df004ffd34b93b1ddb02ed5987bd | |
parent | f5d920eb2e0170b5abf565686cd1284475a77cb1 (diff) | |
download | serenity-526ca6878629865a1f535552abbfcd17d7e04326.zip |
SystemMonitor: Correctly check error of posix_spawn()
posix_spawn() has a bit of a whacky API in that it doens't return
0 on success and -1 on failure while writing the error code to
errno -- it instead returns 0 on success and the error code on
error.
So assign the return value to errno so that perror() does the
right thing.
-rw-r--r-- | Applications/SystemMonitor/main.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 79f6c2bc19..ae585e4bc9 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -214,7 +214,7 @@ int main(int argc, char** argv) auto pid_string = String::format("%d", pid); pid_t child; const char* argv[] = { "/bin/Profiler", "--pid", pid_string.characters(), nullptr }; - if (posix_spawn(&child, "/bin/Profiler", nullptr, nullptr, const_cast<char**>(argv), environ) < 0) { + if ((errno = posix_spawn(&child, "/bin/Profiler", nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); } } |