Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practicum6 / ex2.c
diff options
context:
space:
mode:
1 files changed, 17 insertions, 0 deletions
-rw-r--r--Year 3/System programming/Practicum6/ex2.c17
diff --git a/Year 3/System programming/Practicum6/ex2.c b/Year 3/System programming/Practicum6/ex2.c
new file mode 100644
index 0000000..c64ac9e
--- /dev/null
+++ b/Year 3/System programming/Practicum6/ex2.c
@@ -0,0 +1,17 @@
+#include <unistd.h>
+#include <stdio.h>
+
+int main() {
+ int fileDes[2];
+ if (pipe(fileDes) < 0) {
+ perror("pipe");
+ return 1;
+ }
+ if (close(fileDes[0]) < 0) {
+ perror("close");
+ return 2;
+ }
+ char buf = 'a';
+ write(fileDes[1], &buf, 1);
+ return 0;
+}