[TESTS] Make test09 deterministic (#698)

This commit is contained in:
Yang Liu 2023-04-14 02:00:56 +08:00 committed by GitHub
parent 9246f4925b
commit 8a903f1e2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

Binary file not shown.

View File

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
void forkexample() void forkexample()
@ -9,7 +10,7 @@ void forkexample()
if (fork() == 0) if (fork() == 0)
printf("Child has x = %d\n", ++x); printf("Child has x = %d\n", ++x);
else { else {
usleep(20000); wait(NULL);
printf("Parent has x = %d\n", --x); printf("Parent has x = %d\n", --x);
} }
} }