diff options
[SP/P13] Solved first two exercises
1 files changed, 25 insertions, 0 deletions
| -rw-r--r-- | Year 3/System programming/Practice13/ex1.c | 25 |
diff --git a/Year 3/System programming/Practice13/ex1.c b/Year 3/System programming/Practice13/ex1.c new file mode 100644 index 0000000..4ea65cb --- /dev/null +++ b/Year 3/System programming/Practice13/ex1.c @@ -0,0 +1,25 @@ +#include <signal.h> +#include <stdio.h> +#include <unistd.h> + +void handler(int a) {} + +int main() { + signal(SIGUSR1, &handler); + + int fpid = fork(); + if (fpid == 0) { + while (1) { + pause(); + printf("child\n"); + } + } + else { + while (1) { + printf("parent\n"); + kill(fpid, SIGUSR1); + sleep(1); + } + } + return 0; +} |
