2
* Copyright 2009-2010 Bart Trojanowski <bart@jukie.net>
3
* Licensed under GPLv2, or later, at your choosing.
5
* bidirectional popen() call
7
* @param rwepipe - int array of size three
8
* @param exe - program to run
9
* @param argv - argument list
10
* @return pid or -1 on error
12
* The caller passes in an array of three integers (rwepipe), on successful
13
* execution it can then write to element 0 (stdin of exe), and read from
14
* element 1 (stdout) and 2 (stderr).
17
/* Modified by Stephen Paul Weber to take a path and pass it to sh -c */
25
int popenRWE(int *rwepipe, const char *path) {
31
const char *argv[4] = {"sh", "-c", NULL, NULL};
47
if (pid > 0) { /* parent */
55
} else if (pid == 0) { /* child */
66
execvp(argv[0], (char**)argv);
86
int pcloseRWE(int pid, int *rwepipe) {
91
rc = waitpid(pid, &status, 0);