From: Francis Deslauriers Date: Wed, 12 Feb 2020 20:30:16 +0000 (-0500) Subject: Tests: Cleanup: notification: `assert()` that `app_pid` is set X-Git-Tag: v2.13.0-rc1~294 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7344b6a307b62685272f8f5dacc42d4e06e5732f;p=lttng-tools.git Tests: Cleanup: notification: `assert()` that `app_pid` is set According to the kill(2) manpage: If pid equals -1, then sig is sent to every process for which the calling process has permission to send signals, except for process 1 (init), Since our current default value is -1, if we call the `{suspend,resume}_application()` functions before setting the `app_pid` we end up sending a signal to all processes owned by the user which can be pretty dramatic. If we are about to call `kill()` with -1, it's a logic error so we can assert(). Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: I211f75d44e6cfdd2f2e35ef342b930eb683dbbe5 Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479 --- diff --git a/tests/regression/tools/notification/notification.c b/tests/regression/tools/notification/notification.c index d3917b478..631948cda 100644 --- a/tests/regression/tools/notification/notification.c +++ b/tests/regression/tools/notification/notification.c @@ -43,7 +43,7 @@ int nb_args = 0; int named_pipe_args_start = 0; -pid_t app_pid = -1; +pid_t app_pid = 0; const char *app_state_file = NULL; static @@ -156,6 +156,8 @@ int suspend_application(void) /* * Send SIGUSR1 to application instructing it to bypass tracepoint. */ + assert(app_pid > 1); + ret = kill(app_pid, SIGUSR1); if (ret) { fail("SIGUSR1 failed. errno %d", errno); @@ -186,6 +188,8 @@ int resume_application(void) goto error; } + assert(app_pid > 1); + ret = kill(app_pid, SIGUSR1); if (ret) { fail("SIGUSR1 failed. errno %d", errno);