summaryrefslogtreecommitdiff
path: root/src/stdio/pclose.c
diff options
context:
space:
mode:
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)
+*/
+