diff options
author | Frans Kaashoek <[email protected]> | 2020-11-05 17:32:35 -0500 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2020-11-05 19:50:46 -0500 |
commit | ef97f65025b3704a90fbde79ef3ce3a38bcb6899 (patch) | |
tree | f883cd4bf5f458643ebd0a4092f4e710e46f5525 /user/usertests.c | |
parent | b4c2851bb347d5243a4498fdd9e1f0c9a23e6498 (diff) | |
download | xv6-labs-ef97f65025b3704a90fbde79ef3ce3a38bcb6899.tar.gz xv6-labs-ef97f65025b3704a90fbde79ef3ce3a38bcb6899.tar.bz2 xv6-labs-ef97f65025b3704a90fbde79ef3ce3a38bcb6899.zip |
kill/status test
Diffstat (limited to 'user/usertests.c')
-rw-r--r-- | user/usertests.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/user/usertests.c b/user/usertests.c index ec6630d..9be687a 100644 --- a/user/usertests.c +++ b/user/usertests.c @@ -779,6 +779,36 @@ pipe1(char *s) } } + +// test if child is killed (status = -1) +void +killstatus(char *s) +{ + int xst; + + for(int i = 0; i < 100; i++){ + int pid1 = fork(); + if(pid1 < 0){ + printf("%s: fork failed\n", s); + exit(1); + } + if(pid1 == 0){ + for (int j = 0; j < 1000; j++) { + getpid(); + } + exit(0); + } + sleep(1); + kill(pid1); + wait(&xst); + if(xst != -1) { + printf("%s: status should be -1\n", s); + exit(1); + } + } + exit(0); +} + // meant to be run w/ at most two CPUs void preempt(char *s) @@ -2786,6 +2816,7 @@ main(int argc, char *argv[]) {iputtest, "iput"}, {mem, "mem"}, {pipe1, "pipe1"}, + {killstatus, "killstatus"}, {preempt, "preempt"}, {exitwait, "exitwait"}, {rmdot, "rmdot"}, |