26 #if defined (HAVE_CONFIG_H)
39 #if defined (HAVE_UNISTD_H)
40 # if defined (HAVE_SYS_TYPES_H)
41 # include <sys/types.h>
60 #if ! defined (SHELL_PATH)
61 # define SHELL_PATH "/bin/sh"
67 #if (! (defined (__CYGWIN__) || defined (__MINGW32__) || defined (_MSC_VER)) \
68 && defined (HAVE_UNISTD_H))
70 static procbuf *procbuf_list =
nullptr;
74 #if ! defined (BUFSIZ)
81 #if defined (__CYGWIN__) || defined (__MINGW32__) || defined (_MSC_VER)
97 if (mode & std::ios::out)
102 #elif defined (HAVE_UNISTD_H)
106 volatile int child_std_end = (mode & std::ios::in) ? 1 : 0;
108 volatile int parent_end, child_end;
116 if (mode & std::ios::in)
118 parent_end = pipe_fds[0];
119 child_end = pipe_fds[1];
123 parent_end = pipe_fds[1];
124 child_end = pipe_fds[0];
133 if (child_end != child_std_end)
141 FILE *fp = procbuf_list->
m_f;
149 procbuf_list = procbuf_list->
m_next;
152 execl (
SHELL_PATH,
"sh",
"-c", command,
static_cast<void *
> (
nullptr));
165 m_f = (::fdopen (parent_end, (mode & std::ios::in) ?
"r" :
"w"));
167 if (mode & std::ios::out)
168 ::setvbuf (
m_f,
nullptr, _IOLBF,
BUFSIZ);
187 #if defined (__CYGWIN__) || defined (__MINGW32__) || defined (_MSC_VER)
199 #elif defined (HAVE_UNISTD_H)
207 for (
procbuf **ptr = &procbuf_list;
213 *ptr = (*ptr)->m_next;
219 if (status == 0 && std::fclose (
m_f) == 0)
227 while (wait_pid == -1 && errno == EINTR);
procbuf * open(const char *command, int mode)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
pid_t fork(std::string &msg)
pid_t waitpid(pid_t pid, int *status, int options)
FILE * popen(const char *command, const char *mode)
int octave_close_wrapper(int fd)
int octave_dup2_wrapper(int fd1, int fd2)