Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice13 / ex1.c
diff options
context:
space:
mode:
Commit0e7e0faf753e10175b1ea6406299d9f0cca81962 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-01-21 14:58:12 +0200
Committer
 Syndamia <kamen@syndamia.com>
2024-01-21 14:58:12 +0200
Files4213b569be27e4795037a64837215ef238c80422 /Year 3/System programming/Practice13/ex1.c
uni-projects-0e7e0faf753e10175b1ea6406299d9f0cca81962.tar
uni-projects-0e7e0faf753e10175b1ea6406299d9f0cca81962.tar.gz
uni-projects-0e7e0faf753e10175b1ea6406299d9f0cca81962.zip
Parent2dc3695bf5e288779741f95629ba6ec9e1cbee8c (diff)
[SP/P13] Solved first two exercises
1 files changed, 25 insertions, 0 deletions
-rw-r--r--Year 3/System programming/Practice13/ex1.c25
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;
+}