summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-07-07 06:39:31 -0400
committerRobert Morris <[email protected]>2019-07-07 06:39:31 -0400
commit62313be582a5abd3a114eec3c9f5770ea37ef766 (patch)
tree9c6730192d454118ce17a430ec6de30214b43e8d /user
parentbe88befed702f7bcbf65212a9dcf9456a7bd2ae1 (diff)
downloadxv6-labs-62313be582a5abd3a114eec3c9f5770ea37ef766.tar.gz
xv6-labs-62313be582a5abd3a114eec3c9f5770ea37ef766.tar.bz2
xv6-labs-62313be582a5abd3a114eec3c9f5770ea37ef766.zip
another fork test
Diffstat (limited to 'user')
-rw-r--r--user/usertests.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/user/usertests.c b/user/usertests.c
index 199346c..9d46b1a 100644
--- a/user/usertests.c
+++ b/user/usertests.c
@@ -507,6 +507,40 @@ twochildren(void)
}
void
+forkforkfork(void)
+{
+ printf(1, "forkforkfork test\n");
+
+ unlink("stopforking");
+
+ int pid = fork();
+ if(pid < 0){
+ printf(1, "fork failed");
+ exit();
+ }
+ if(pid == 0){
+ while(1){
+ int fd = open("stopforking", 0);
+ if(fd >= 0){
+ exit();
+ }
+ if(fork() < 0){
+ close(open("stopforking", O_CREATE|O_RDWR));
+ }
+ }
+
+ exit();
+ }
+
+ sleep(2);
+ close(open("stopforking", O_CREATE|O_RDWR));
+ wait();
+ sleep(1);
+
+ printf(1, "forkforkfork ok\n");
+}
+
+void
mem(void)
{
void *m1, *m2;
@@ -1824,6 +1858,7 @@ main(int argc, char *argv[])
reparent();
twochildren();
+ forkforkfork();
argptest();
createdelete();