sc_popen.h 1.09 KB
Newer Older
1 2 3
#include <stdio.h>
#include <sys/types.h>

4
#ifndef _WIN32
5 6 7 8
#include <unistd.h>
#include <sys/wait.h>
#endif

9
#ifdef _WIN32
10
#include "SC_Win32Utils.h"
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 *	Signal stuff
 *	For WIN32, there is no wait() call so there are no wait() macros
 *	to interpret the return value of system().  Instead, system()
 *	return values < 0x100 are used for exit() termination, and higher
 *	values are used to indicated non-exit() termination, which is
 *	similar to a unix-style signal exit (think SIGSEGV ==
 *	STATUS_ACCESS_VIOLATION).  See this URL for a list of WIN32
 *	STATUS_* values from Wine:
 *
 *		http://source.winehq.org/source/include/ntstatus.h
 */
#define WIFEXITED(w)    (((w) & 0xffffff00) == 0)
#define WIFSIGNALED(w)  (!WIFEXITED(w))
#define WEXITSTATUS(w)  (w)
#define WTERMSIG(w)     (w)
#endif

29 30 31 32
/** \brief Opens a pipe to a separate process.
 *
 * This function assumes a UTF-8 encoded, narrow-char string.
 */
33
FILE * sc_popen(const char *command, pid_t *pidp, const char *type);
34

35
FILE * sc_popen_argv(const char *filename, char *const argv[], pid_t *pidp, const char *type);
36
int sc_pclose(FILE *iop, pid_t mPid);