summaryrefslogtreecommitdiff
path: root/src/stdio/pclose.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-09 16:57:14 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-09 16:57:14 -0500
commitc2df77a517e8651a07e323aaa18c6caa2d77eb1b (patch)
tree88ca7ec8494332234a7ff201dac333bd6bf7f0e8 /src/stdio/pclose.c
parent7958762d8b94f0aa3babe1d5a8cf0cd57eb3b88f (diff)
merge POSIX.2 identifiers
Diffstat (limited to 'src/stdio/pclose.c')
-rw-r--r--src/stdio/pclose.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/stdio/pclose.c b/src/stdio/pclose.c
new file mode 100644
index 00000000..7a70bf9f
--- /dev/null
+++ b/src/stdio/pclose.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include "sys/wait.h"
+
+int pclose(FILE * stream)
+{
+ int status;
+ pid_t child = stream->pipe_pid;
+ if (child == 0) {
+ /* undefined behavior */
+ }
+
+ fclose(stream);
+
+ waitpid(pid, &status, 0);
+ return status;
+}
+
+/*
+POSIX(2)
+*/
+