kill/status test

This commit is contained in:
Frans Kaashoek 2020-11-05 17:32:35 -05:00
parent b63d3506e9
commit d7b308fe81

View file

@ -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 // meant to be run w/ at most two CPUs
void void
preempt(char *s) preempt(char *s)
@ -2786,6 +2816,7 @@ main(int argc, char *argv[])
{iputtest, "iput"}, {iputtest, "iput"},
{mem, "mem"}, {mem, "mem"},
{pipe1, "pipe1"}, {pipe1, "pipe1"},
{killstatus, "killstatus"},
{preempt, "preempt"}, {preempt, "preempt"},
{exitwait, "exitwait"}, {exitwait, "exitwait"},
{rmdot, "rmdot"}, {rmdot, "rmdot"},