summaryrefslogtreecommitdiffstats
path: root/src/test/test-pidref.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2025-01-13 11:04:19 +0100
committerLennart Poettering <lennart@poettering.net>2025-01-16 11:55:21 +0100
commit6eeeef9f66d2ce17e9ee8e5f2168c00e20ffb412 (patch)
treed816ff629d7b63550cd9b4f443ce16f454f39fb4 /src/test/test-pidref.c
parentpidref: various shortcuts to pidref_equal() (diff)
downloadsystemd-6eeeef9f66d2ce17e9ee8e5f2168c00e20ffb412.tar.xz
systemd-6eeeef9f66d2ce17e9ee8e5f2168c00e20ffb412.zip
process-util: introduce new FORK_FREEZE flag for safe_fork()
Often we want to fork off a process that just hangs until we kill it, let's add a simple flag to create one of this type, and use it at various places.
Diffstat (limited to '')
-rw-r--r--src/test/test-pidref.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/test/test-pidref.c b/src/test/test-pidref.c
index 5535e98ab0..10033b5826 100644
--- a/src/test/test-pidref.c
+++ b/src/test/test-pidref.c
@@ -159,12 +159,8 @@ TEST(pidref_new_from_pid) {
TEST(pidref_kill) {
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
siginfo_t si;
- int r;
- r = pidref_safe_fork("(test-pidref-kill)", FORK_DEATHSIG_SIGKILL, &pidref);
- assert_se(r >= 0);
- if (r == 0)
- freeze();
+ ASSERT_OK_POSITIVE(pidref_safe_fork("(test-pidref-kill)", FORK_DEATHSIG_SIGKILL|FORK_FREEZE, &pidref));
assert_se(pidref_kill(&pidref, SIGKILL) >= 0);
assert_se(pidref_wait_for_terminate(&pidref, &si) >= 0);
@@ -174,12 +170,8 @@ TEST(pidref_kill) {
TEST(pidref_kill_and_sigcont) {
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
siginfo_t si;
- int r;
- r = pidref_safe_fork("(test-pidref-kill-and-sigcont)", FORK_DEATHSIG_SIGTERM, &pidref);
- assert_se(r >= 0);
- if (r == 0)
- freeze();
+ ASSERT_OK_POSITIVE(pidref_safe_fork("(test-pidref-kill-and-sigcont)", FORK_DEATHSIG_SIGTERM|FORK_FREEZE, &pidref));
assert_se(pidref_kill_and_sigcont(&pidref, SIGTERM) >= 0);
assert_se(pidref_wait_for_terminate(&pidref, &si) >= 0);
@@ -189,12 +181,8 @@ TEST(pidref_kill_and_sigcont) {
TEST(pidref_sigqueue) {
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
siginfo_t si;
- int r;
- r = pidref_safe_fork("(test-pidref-sigqueue)", FORK_DEATHSIG_SIGTERM, &pidref);
- assert_se(r >= 0);
- if (r == 0)
- freeze();
+ ASSERT_OK_POSITIVE(pidref_safe_fork("(test-pidref-sigqueue)", FORK_DEATHSIG_SIGTERM|FORK_FREEZE, &pidref));
assert_se(pidref_sigqueue(&pidref, SIGTERM, 42) >= 0);
assert_se(pidref_wait_for_terminate(&pidref, &si) >= 0);
@@ -203,12 +191,8 @@ TEST(pidref_sigqueue) {
TEST(pidref_done_sigkill_wait) {
_cleanup_(pidref_done_sigkill_wait) PidRef pidref = PIDREF_NULL;
- int r;
- r = pidref_safe_fork("(test-pidref-done-sigkill-wait)", FORK_DEATHSIG_SIGKILL, &pidref);
- assert_se(r >= 0);
- if (r == 0)
- freeze();
+ ASSERT_OK_POSITIVE(pidref_safe_fork("(test-pidref-done-sigkill-wait)", FORK_DEATHSIG_SIGKILL|FORK_FREEZE, &pidref));
}
TEST(pidref_verify) {