system() is supposed to return a waitpid() style exit status value.

wait_for_thread() doesn't provide that; use waitpid() instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28479 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-11-03 16:35:09 +00:00
parent 44e4ddfdc1
commit 3cbd4a09f7
+19 -17
View File
@@ -1,14 +1,14 @@
/* /*
** Copyright 2004, Ingo Weinhold, [email protected]. All rights reserved. * Copyright 2004-2008, Ingo Weinhold, [email protected].
** Distributed under the terms of the Haiku License. * Distributed under the terms of the MIT License.
*/ */
#include <image.h> #include <image.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
extern "C" int extern "C" int
@@ -26,15 +26,17 @@ system(const char *command)
return -1; return -1;
} }
status_t returnValue; resume_thread(thread);
status_t error;
do { int exitStatus;
error = wait_for_thread(thread, &returnValue); pid_t result;
} while (error == B_INTERRUPTED); while ((result = waitpid(thread, &exitStatus, 0)) < 0
&& errno == B_INTERRUPTED) {
if (error != B_OK) { // waitpid() was interrupted by a signal, retry...
errno = error;
return -1;
} }
return returnValue;
if (result < 0)
return -1;
return exitStatus;
} }