Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/zdtm/static/child_subreaper.c')
-rw-r--r--test/zdtm/static/child_subreaper.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/zdtm/static/child_subreaper.c b/test/zdtm/static/child_subreaper.c
new file mode 100644
index 000000000..267795249
--- /dev/null
+++ b/test/zdtm/static/child_subreaper.c
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <sys/prctl.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check that child subreaper attribute is restored";
+const char *test_author = "Michał Cłapiński <mclapinski@google.com>";
+
+int main(int argc, char **argv)
+{
+ test_init(argc, argv);
+
+ int cs_before = 1;
+ int ret = prctl(PR_SET_CHILD_SUBREAPER, cs_before, 0, 0, 0);
+ if (ret) {
+ pr_perror("Can't set child subreaper attribute, err = %d", ret);
+ exit(1);
+ }
+
+ test_daemon();
+ test_waitsig();
+
+ int cs_after;
+ ret = prctl(PR_GET_CHILD_SUBREAPER, (unsigned long)&cs_after, 0, 0, 0);
+ if (ret) {
+ pr_perror("Can't get child subreaper attribute, err = %d", ret);
+ exit(1);
+ }
+
+ if (cs_before != cs_after)
+ fail("%d != %d\n", cs_before, cs_after);
+ else
+ pass();
+
+ return 0;
+}