From 5753553213df8f9de851adb68377db43faecb91f Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Tue, 11 Jun 2019 09:57:14 -0400 Subject: separate source into kernel/ user/ mkfs/ --- user/forktest.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 user/forktest.c (limited to 'user/forktest.c') diff --git a/user/forktest.c b/user/forktest.c new file mode 100644 index 0000000..be4915e --- /dev/null +++ b/user/forktest.c @@ -0,0 +1,56 @@ +// Test that fork fails gracefully. +// Tiny executable so that the limit can be filling the proc table. + +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h" + +#define N 1000 + +void +printf(int fd, const char *s, ...) +{ + write(fd, s, strlen(s)); +} + +void +forktest(void) +{ + int n, pid; + + printf(1, "fork test\n"); + + for(n=0; n 0; n--){ + if(wait() < 0){ + printf(1, "wait stopped early\n"); + exit(); + } + } + + if(wait() != -1){ + printf(1, "wait got too many\n"); + exit(); + } + + printf(1, "fork test OK\n"); +} + +int +main(void) +{ + forktest(); + exit(); +} -- cgit v1.2.3