2
0
Эх сурвалжийг харах

bugfix process exit code detection with WNOHANG

Nicolas Cannasse 7 жил өмнө
parent
commit
1f5a09f491
1 өөрчлөгдсөн 6 нэмэгдсэн , 5 устгасан
  1. 6 5
      src/std/process.c

+ 6 - 5
src/std/process.c

@@ -246,15 +246,16 @@ HL_PRIM int hl_process_exit( vprocess *p, bool *running ) {
 	}
 	return rval;
 #	else
-	int rval;
+	int rval = 0;
 	int wret = waitpid(p->pid,&rval,running ? WNOHANG : 0);
 	if( running ) *running = false;
 	if( wret != p->pid ) {
-		if( running && wret == 0 ) {
-			*running = true;
+		if( running ) {
+			if( wret == 0 )
+				*running = true;
 			return 0;
-		}
-		return -1;
+		} else
+			return -1;
 	}
 	if( !WIFEXITED(rval) ) {
 		if( WIFSIGNALED(rval) )