Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice08 / ex2.c
diff options
context:
space:
mode:
1 files changed, 20 insertions, 0 deletions
-rw-r--r--Year 3/System programming/Practice08/ex2.c20
diff --git a/Year 3/System programming/Practice08/ex2.c b/Year 3/System programming/Practice08/ex2.c
new file mode 100644
index 0000000..c8e783e
--- /dev/null
+++ b/Year 3/System programming/Practice08/ex2.c
@@ -0,0 +1,20 @@
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+void sigpipeHandle(int a) {
+ printf("handler\n");
+}
+
+int main() {
+ signal(SIGPIPE, sigpipeHandle);
+
+ int filedes[2];
+ pipe(filedes);
+ close(filedes[0]);
+
+ write(filedes[1], "aba\n", 4);
+ write(1, "mnm\n", 4);
+
+ return 0;
+}