summaryrefslogtreecommitdiff
path: root/regress/sys/kern/rfork
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-02-17 05:16:42 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-02-17 05:16:42 +0000
commit58df721bc6c127d7dab01b4069cbfa96b89716f6 (patch)
treed396f74548bec04cb9e97b19eb6374fa09c1f971 /regress/sys/kern/rfork
parent8aa2355c66828bbeba88f78424fc3a366eaa38dd (diff)
test rfork(RFCFDG)
Diffstat (limited to 'regress/sys/kern/rfork')
-rw-r--r--regress/sys/kern/rfork/rfcfdg/Makefile5
-rw-r--r--regress/sys/kern/rfork/rfcfdg/rfcfdg.c38
2 files changed, 43 insertions, 0 deletions
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 <bsd.regress.mk>
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 <art@openbsd.org>, 2002 Public Domain.
+ */
+#include <sys/param.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <err.h>
+#include <fcntl.h>
+
+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