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 <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I211f75d44e6cfdd2f2e35ef342b930eb683dbbe5
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479
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
/*
* 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);
goto error;
}
+ assert(app_pid > 1);
+
ret = kill(app_pid, SIGUSR1);
if (ret) {
fail("SIGUSR1 failed. errno %d", errno);