#ifndef RUN_COMMAND_H
#define RUN_COMMAND_H
+#ifndef NO_PTHREADS
+#include <pthread.h>
+#endif
+
struct child_process {
const char **argv;
pid_t pid;
* - Specify > 0 to set a channel to a particular FD as follows:
* .in: a readable FD, becomes child's stdin
* .out: a writable FD, becomes child's stdout/stderr
- * .err > 0 not supported
+ * .err: a writable FD, becomes child's stderr
* The specified FD is closed by start_command(), even in case
* of errors!
*/
*/
struct async {
/*
- * proc writes to fd and closes it;
+ * proc reads from in; closes it before return
+ * proc writes to out; closes it before return
* returns 0 on success, non-zero on failure
*/
- int (*proc)(int fd, void *data);
+ int (*proc)(int in, int out, void *data);
void *data;
+ int in; /* caller writes here and closes it */
int out; /* caller reads from here and closes it */
-#ifndef WIN32
+#ifdef NO_PTHREADS
pid_t pid;
#else
- HANDLE tid;
- int fd_for_proc;
+ pthread_t tid;
+ int proc_in;
+ int proc_out;
#endif
};