diff options
author | Frans Kaashoek <[email protected]> | 2020-11-05 17:32:35 -0500 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2020-11-05 18:50:02 -0500 |
commit | d7b308fe81b9fdee1f6060f847b37a252214266a (patch) | |
tree | f883cd4bf5f458643ebd0a4092f4e710e46f5525 | |
parent | b63d3506e9fbe7db1cd117db746fb58b7712ab4f (diff) | |
download | xv6-labs-d7b308fe81b9fdee1f6060f847b37a252214266a.tar.gz xv6-labs-d7b308fe81b9fdee1f6060f847b37a252214266a.tar.bz2 xv6-labs-d7b308fe81b9fdee1f6060f847b37a252214266a.zip |
kill/status test
-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"}, |