This commit is contained in:
Nikita Ivanov 2022-08-02 22:17:56 +05:00
parent d09539f627
commit 7919d67e21
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133

View File

@ -5,16 +5,14 @@
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
int main (int argc, char *argv[]) int main(int argc, char *argv[])
{ {
if (argc <= 1) { if (argc <= 1) {
fprintf(stderr, "id not given\n"); fprintf(stderr, "id not given\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
char *pid_s = argv[1]; char *endptr, *pid_s = argv[1];
char *endptr;
errno = 0; errno = 0;
long pid = strtol(pid_s, &endptr, 10); long pid = strtol(pid_s, &endptr, 10);
@ -30,7 +28,7 @@ int main (int argc, char *argv[])
} }
while (1) { while (1) {
sleep(5); sleep(1);
if (kill(pid, 0) == -1) { if (kill(pid, 0) == -1) {
if (errno != ESRCH) { if (errno != ESRCH) {