Check if PID is running before starting to monitor

This commit is contained in:
Konstantin Pereiaslov
2024-01-05 02:23:45 -06:00
parent 411463b319
commit 395d43dc05

4
main.c
View File

@@ -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;