24 #include <sys/types.h>
51 open (
const string& cmd_,
const string& type_)
55 #if !defined(WIN32) // not yet implemented
57 if (type_ !=
"r" && type_ !=
"w") {
58 EL((
ASSAERR,
"Wrong type \"%s\"\n", type_.c_str ()));
73 if (fd [1] != STDOUT_FILENO) {
74 dup2 (fd [1], STDOUT_FILENO);
80 if (fd [0] != STDIN_FILENO) {
81 dup2 (fd [0], STDIN_FILENO);
86 DL((
PIPE,
"Executing cmd: \"%s\"\n", cmd_.c_str ()));
87 execl (
"/bin/sh",
"sh",
"-c", cmd_.c_str (), (
char* ) 0);
94 if ((
m_fp = fdopen (fd [0], type_.c_str ())) == NULL) {
101 if ((
m_fp = fdopen (fd [1], type_.c_str ())) == NULL) {
150 return ret == EOF ? -1 : 0;