From 395d43dc05bd8767423e7edca052f160207e3b81 Mon Sep 17 00:00:00 2001 From: Konstantin Pereiaslov Date: Fri, 5 Jan 2024 02:23:45 -0600 Subject: [PATCH] Check if PID is running before starting to monitor --- main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.c b/main.c index a327e6a..17e969a 100644 --- a/main.c +++ b/main.c @@ -178,6 +178,10 @@ int main(int argc, char *argv[]) { pid = run_shell_command(shell_command_to_run); } else { pid = external_pid; + if (kill(pid, 0) == -1) { + fprintf_error("PID %d is not running\n", pid); + exit(1); + } } free(shell_command_to_run); struct timespec time_when_command_started;