379_demos/lab1/demos/kill.c
2024-09-24 13:34:24 -06:00

19 lines
382 B
C

#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
int main(void) {
int pid = fork();
if (pid == 0) {
printf("Child with pid %d\n", getpid());
while (1) {
printf("*");
}
} else {
sleep(1);
kill(pid, SIGKILL);
printf("\nParent killed pid %d with signal %d\n", pid, SIGKILL);
}
}