From: Michael Tremer Date: Tue, 13 Dec 2022 11:17:32 +0000 (+0000) Subject: tests: jail: Send signals to ourselves X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=72d37c72d0337fc01b4c5ea7ebab16c95a8224df;p=people%2Fstevee%2Fpakfire.git tests: jail: Send signals to ourselves This should not cause the parent process to die. Signed-off-by: Michael Tremer --- diff --git a/tests/libpakfire/jail.c b/tests/libpakfire/jail.c index 784e89ef..cd71f29b 100644 --- a/tests/libpakfire/jail.c +++ b/tests/libpakfire/jail.c @@ -383,6 +383,42 @@ FAIL: return r; } +static int test_send_one_signal(const struct test* t, + struct pakfire_jail* jail, const char* signal) { + const char* argv[] = { + "/command", "send-signal", signal, NULL, + }; + + // Perform the command + return pakfire_jail_exec(jail, argv, NULL, NULL, NULL); +} + +static int test_send_signal(const struct test* t) { + struct pakfire_jail* jail = NULL; + int r = EXIT_FAILURE; + + // Create a new jail + ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire, 0)); + + // Sending SIGTERM to ourselves + ASSERT(test_send_one_signal(t, jail, "15") == 0); + + // Sending SIGKILL to ourselves + ASSERT(test_send_one_signal(t, jail, "9") == 0); + + // Sending SIGSTOP to ourselves (this should be ignored by the jail) + ASSERT(test_send_one_signal(t, jail, "23") == 0); + + // Success + r = EXIT_SUCCESS; + +FAIL: + if (jail) + pakfire_jail_unref(jail); + + return r; +} + int main(int argc, const char* argv[]) { testsuite_add_test(test_create); testsuite_add_test(test_exit_code); @@ -396,6 +432,7 @@ int main(int argc, const char* argv[]) { testsuite_add_test(test_file_ownership); testsuite_add_test(test_bind); testsuite_add_test(test_communicate); + testsuite_add_test(test_send_signal); return testsuite_run(argc, argv); }