summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
Diffstat (limited to 'regress')
-rw-r--r--regress/sys/kern/rlimit-file/Makefile5
-rw-r--r--regress/sys/kern/rlimit-file/rlim-file.c33
2 files changed, 38 insertions, 0 deletions
diff --git a/regress/sys/kern/rlimit-file/Makefile b/regress/sys/kern/rlimit-file/Makefile
new file mode 100644
index 00000000000..0bf3447a702
--- /dev/null
+++ b/regress/sys/kern/rlimit-file/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2002/02/05 16:19:49 art Exp $
+
+PROG= rlim-file
+
+.include <bsd.regress.mk>
diff --git a/regress/sys/kern/rlimit-file/rlim-file.c b/regress/sys/kern/rlimit-file/rlim-file.c
new file mode 100644
index 00000000000..183c2b64966
--- /dev/null
+++ b/regress/sys/kern/rlimit-file/rlim-file.c
@@ -0,0 +1,33 @@
+/* $OpenBSD: rlim-file.c,v 1.1 2002/02/05 16:19:49 art Exp $ */
+/*
+ * Written by Artur Grabowski <art@openbsd.org> (2002) Public Domain.
+ */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <err.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+int
+main()
+{
+ int lim, fd, fds[2];
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
+ err(1, "getrlimit");
+
+ lim = rl.rlim_cur;
+
+ fd = -1;
+ while (fd < lim - 2)
+ if ((fd = open("/dev/null", O_RDONLY)) < 0)
+ err(1, "open");
+
+ if (pipe(fds) == 0)
+ errx(1, "pipe was allowed");
+
+ return 0;
+}
+