From 0e7e0faf753e10175b1ea6406299d9f0cca81962 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 21 Jan 2024 14:58:12 +0200 Subject: [SP/P13] Solved first two exercises --- Year 3/System programming/Practice13/ex1.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Year 3/System programming/Practice13/ex1.c (limited to 'Year 3/System programming/Practice13/ex1.c') 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 +#include +#include + +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; +} -- cgit v1.3.1-26-gb76a