Skip to content

Commit

Permalink
kill/status test
Browse files Browse the repository at this point in the history
  • Loading branch information
kaashoek committed Nov 6, 2020
1 parent b4c2851 commit ef97f65
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions user/usertests.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -2786,6 +2816,7 @@ main(int argc, char *argv[])
{iputtest, "iput"},
{mem, "mem"},
{pipe1, "pipe1"},
{killstatus, "killstatus"},
{preempt, "preempt"},
{exitwait, "exitwait"},
{rmdot, "rmdot"},
Expand Down

0 comments on commit ef97f65

Please sign in to comment.