aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2018-01-21 16:26:30 +0100
committerLeah Neukirchen <leah@vuxu.org>2018-01-21 16:26:30 +0100
commit3a867c9ba4f41dad6c67a1a08792b358f328c54b (patch)
treeb1a78317a86069785124441284edbbd7c81c899c
parent2dda99039012b3605bda62d2373d526d914a6855 (diff)
downloadfail-3a867c9ba4f41dad6c67a1a08792b358f328c54b.tar.gz
fail-3a867c9ba4f41dad6c67a1a08792b358f328c54b.tar.xz
fail-3a867c9ba4f41dad6c67a1a08792b358f328c54b.zip
add -D to generate a process in uninterruptible sleep
-rw-r--r--fail.19
-rw-r--r--fail.c13
2 files changed, 20 insertions, 2 deletions
diff --git a/fail.1 b/fail.1
index c5af510..d63ea57 100644
--- a/fail.1
+++ b/fail.1
@@ -6,7 +6,7 @@
.Nd crash in various possible ways
.Sh SYNOPSIS
.Nm
-.Op Fl 123Oacdikrst
+.Op Fl 123DOacdikrst
.Sh DESCRIPTION
.Nm
crashes in various possible ways to
@@ -27,6 +27,13 @@ Return with exit status -1.
Return with exit status 2.
.It Fl 3
Return with exit status 111.
+.It Fl D
+Create a process that is in uninterruptible sleep (state D) and
+print its pid.
+(This uses
+.Xr vfork 2
+and
+.Xr pause 2 . )
.It Fl O
Allocate memory in an infinite loop,
to trigger an out of memory situation.
diff --git a/fail.c b/fail.c
index f586ba8..6e986ee 100644
--- a/fail.c
+++ b/fail.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -34,6 +35,15 @@ dlcrash()
*nullp = 1337;
}
+void
+uninterruptible()
+{
+ printf("pid %d is now in state D\n", getpid());
+ vfork();
+ pause();
+ exit(1);
+}
+
// can lockup your machine
void
oom()
@@ -122,11 +132,12 @@ main(int argc, char *argv[])
{
int c;
- while ((c = getopt(argc, argv, "123Oacdikrst")) != -1) {
+ while ((c = getopt(argc, argv, "123DOacdikrst")) != -1) {
switch (c) {
case '1': exit(-1); break;
case '2': exit(2); break;
case '3': exit(111); break;
+ case 'D': uninterruptible(); break;
case 'O': oom(); break;
case 'a': abortme(); break;
case 'c': violate_seccomp(); break;