Просмотр исходного кода

Fixes Mac parallel build issue.

woollybah 9 лет назад
Родитель
Сommit
470cc0c1b3
1 измененных файлов с 19 добавлено и 18 удалено
  1. 19 18
      waitpid.c

+ 19 - 18
waitpid.c

@@ -1,27 +1,28 @@
 #include <stdio.h>
 
-/*
+#ifndef __WIN32
+#include <stddef.h>
 #include <sys/wait.h>
 #include <errno.h>
+#include <sys/types.h>
+#endif
 
-int bmx_waitpid(pid_t pid) {
-
+int bmx_system(const char * c) {
+#ifdef __WIN32
+	return system(c);
+#else
 	int status;
-	pid_t p = waitpid(pid, &status, WUNTRACED);
-	
-	if (p > 0) {
-		if (WIFEXITED(status)) {
-			return WEXITSTATUS(status);
-		}
-		if (WIFSIGNALED(status)) {
-			return WTERMSIG(status);
-		}
+	pid_t pid = fork();
+	if (pid == 0) {
+		execl("/bin/sh", "/bin/sh", "-c", c, NULL);
+		_exit(-1);
+	} else if (pid < 0) {
+		status = -1;
 	} else {
-		return errno * -1;
+		if (waitpid(pid, &status, 0) != pid) {
+			status = -1;
+		}
 	}
-	return -999;
-}
-*/
-int bmx_system(const char * c) {
-	return system(c);
+	return status;
+#endif
 }