common: prevent buffer overflow
[supercollider.git] / include / common / sc_popen.h
blobd9468c3472bf4b2cf025136db3e7a2308789fa59
1 #include <stdio.h>
2 #include <sys/types.h>
4 #ifdef _WIN32
5 #include <pthread.h>
6 #else
7 #include <unistd.h>
8 #include <sys/wait.h>
9 #endif
11 #ifdef _WIN32
13 * Signal stuff
14 * For WIN32, there is no wait() call so there are no wait() macros
15 * to interpret the return value of system(). Instead, system()
16 * return values < 0x100 are used for exit() termination, and higher
17 * values are used to indicated non-exit() termination, which is
18 * similar to a unix-style signal exit (think SIGSEGV ==
19 * STATUS_ACCESS_VIOLATION). See this URL for a list of WIN32
20 * STATUS_* values from Wine:
22 * http://source.winehq.org/source/include/ntstatus.h
24 #define WIFEXITED(w) (((w) & 0xffffff00) == 0)
25 #define WIFSIGNALED(w) (!WIFEXITED(w))
26 #define WEXITSTATUS(w) (w)
27 #define WTERMSIG(w) (w)
28 #endif
30 FILE * sc_popen(const char *command, pid_t *pidp, const char *type);
31 int sc_pclose(FILE *iop, pid_t mPid);