mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +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:
committed by
Andreas Kling
parent
f5d920eb2e
commit
526ca68786
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user