From 58df721bc6c127d7dab01b4069cbfa96b89716f6 Mon Sep 17 00:00:00 2001 From: Artur Grabowski Date: Sun, 17 Feb 2002 05:16:42 +0000 Subject: test rfork(RFCFDG) --- regress/sys/kern/rfork/rfcfdg/Makefile | 5 +++++ regress/sys/kern/rfork/rfcfdg/rfcfdg.c | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 regress/sys/kern/rfork/rfcfdg/Makefile create mode 100644 regress/sys/kern/rfork/rfcfdg/rfcfdg.c (limited to 'regress/sys/kern/rfork') diff --git a/regress/sys/kern/rfork/rfcfdg/Makefile b/regress/sys/kern/rfork/rfcfdg/Makefile new file mode 100644 index 00000000000..d0fd9ab703b --- /dev/null +++ b/regress/sys/kern/rfork/rfcfdg/Makefile @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile,v 1.1 2002/02/17 05:16:41 art Exp $ + +PROG=rfcfdg + +.include diff --git a/regress/sys/kern/rfork/rfcfdg/rfcfdg.c b/regress/sys/kern/rfork/rfcfdg/rfcfdg.c new file mode 100644 index 00000000000..922f48f0050 --- /dev/null +++ b/regress/sys/kern/rfork/rfcfdg/rfcfdg.c @@ -0,0 +1,38 @@ +/* $OpenBSD: rfcfdg.c,v 1.1 2002/02/17 05:16:41 art Exp $ */ +/* + * Written by Artur Grabowski , 2002 Public Domain. + */ +#include +#include +#include +#include +#include +#include +#include + +int +main() +{ + int status; + + /* Make sure that at least fd 0 is allocated. */ + if (open("/dev/null", O_RDONLY) < 0) + err(1, "open(/dev/null)"); + + switch(rfork(RFCFDG|RFPROC)) { + case -1: + err(1, "fork"); + case 0: + if (open("/dev/null", O_RDONLY) != 0) + _exit(1); /* pretty hard to print to stderr */ + _exit(0); + } + + if (wait(&status) < 0) + err(1, "wait"); + + if (!WIFEXITED(status)) + err(1, "child error"); + + return WEXITSTATUS(status) != 0; +} \ No newline at end of file -- cgit v1.2.3