1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

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.
This commit is contained in:
Nico Weber 2020-07-02 13:49:04 -04:00 committed by Andreas Kling
parent f5d920eb2e
commit 526ca68786

View file

@ -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");
}
}