1
From eb08b8579355c6962e187f27e6c69a8e5e837d2c Mon Sep 17 00:00:00 2001
2
From: Stephen Paul Weber <singpolyma@singpolyma.net>
3
Date: Mon, 7 Oct 2013 13:31:29 -0500
4
Subject: [PATCH] Forgot these files
7
src/core/popenRWE.c | 93 ++++++++++++++++++++++++++++++++++++++++++
8
src/core/popenRWE.h | 7 ++++
9
2 files changed, 100 insertions(+)
10
create mode 100644 src/core/popenRWE.c
11
create mode 100644 src/core/popenRWE.h
14
+++ b/src/core/popenRWE.c
17
+ * Copyright 2009-2010 Bart Trojanowski <bart@jukie.net>
18
+ * Licensed under GPLv2, or later, at your choosing.
20
+ * bidirectional popen() call
22
+ * @param rwepipe - int array of size three
23
+ * @param exe - program to run
24
+ * @param argv - argument list
25
+ * @return pid or -1 on error
27
+ * The caller passes in an array of three integers (rwepipe), on successful
28
+ * execution it can then write to element 0 (stdin of exe), and read from
29
+ * element 1 (stdout) and 2 (stderr).
32
+/* Modified by Stephen Paul Weber to take a path and pass it to sh -c */
36
+#include <sys/wait.h>
38
+#include "popenRWE.h"
40
+int popenRWE(int *rwepipe, const char *path) {
46
+ const char *argv[4] = {"sh", "-c", NULL, NULL};
62
+ if (pid > 0) { /* parent */
67
+ rwepipe[1] = out[0];
68
+ rwepipe[2] = err[0];
70
+ } else if (pid == 0) { /* child */
81
+ execvp(argv[0], (char**)argv);
101
+int pcloseRWE(int pid, int *rwepipe) {
106
+ rc = waitpid(pid, &status, 0);
110
+++ b/src/core/popenRWE.h
115
+int popenRWE(int *rwepipe, const char *path);
116
+int pcloseRWE(int pid, int *rwepipe);