26 #if defined (HAVE_CONFIG_H)
39 #if defined (HAVE_UNISTD_H)
40 # if defined (HAVE_SYS_TYPES_H)
41 # include <sys/types.h>
58 #if ! defined (SHELL_PATH)
59 # define SHELL_PATH "/bin/sh"
65 #if (! (defined (__CYGWIN__) || defined (__MINGW32__) || defined (_MSC_VER)) \
66 && defined (HAVE_UNISTD_H))
72 #if ! defined (BUFSIZ)
79 #if defined (__CYGWIN__) || defined (__MINGW32__) || defined (_MSC_VER)
95 if (mode & std::ios::out)
96 ::setvbuf (
f,
nullptr, _IOLBF,
BUFSIZ);
100 #elif defined (HAVE_UNISTD_H)
104 volatile int child_std_end = (mode & std::ios::in) ? 1 : 0;
106 volatile int parent_end, child_end;
114 if (mode & std::ios::in)
116 parent_end = pipe_fds[0];
117 child_end = pipe_fds[1];
121 parent_end = pipe_fds[1];
122 child_end = pipe_fds[0];
131 if (child_end != child_std_end)
137 while (octave_procbuf_list)
139 FILE *fp = octave_procbuf_list->
f;
147 octave_procbuf_list = octave_procbuf_list->
next;
150 execl (
SHELL_PATH,
"sh",
"-c", command,
static_cast<void *
> (
nullptr));
163 f = (::fdopen (parent_end, (mode & std::ios::in) ?
"r" :
"w"));
165 if (mode & std::ios::out)
166 ::setvbuf (
f,
nullptr, _IOLBF,
BUFSIZ);
170 next = octave_procbuf_list;
171 octave_procbuf_list =
this;
185 #if defined (__CYGWIN__) || defined (__MINGW32__) || defined (_MSC_VER)
197 #elif defined (HAVE_UNISTD_H)
217 if (status == 0 && std::fclose (
f) == 0)
225 while (wait_pid == -1 && errno == EINTR);
octave_procbuf * close(void)
octave_procbuf * open(const char *command, int mode)
pid_t waitpid(pid_t pid, int *status, int options)
pid_t fork(std::string &msg)
FILE * popen(const char *command, const char *mode)
int octave_close_wrapper(int fd)
int octave_dup2_wrapper(int fd1, int fd2)