Add a simple program to test audit listener
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Tue, 9 May 2017 09:41:09 +0000 (11:41 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 10 May 2017 18:49:57 +0000 (20:49 +0200)
This is just a process which leaks file descriptors.
To test audit listener just run faultd and then this
program.

tests/leaker.c [new file with mode: 0644]

diff --git a/tests/leaker.c b/tests/leaker.c
new file mode 100644 (file)
index 0000000..592d6a7
--- /dev/null
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+
+int main()
+{
+       int i;
+       int fd;
+
+       struct rlimit limits = {
+               .rlim_cur = 16,
+               .rlim_max = 16,
+       };
+
+       setrlimit(RLIMIT_NOFILE, &limits);
+
+       for (i = 0; i < 100; ++i) {
+               fd = open("/dev/null", O_RDONLY);
+               if (fd < 0) {
+                       printf("%d fds, error: %d\n", i, errno);
+                       break;
+               }
+       }
+
+       return 0;
+}