--- ray/src/common/rtprocess.h 2003/06/27 06:53:21 3.2 +++ ray/src/common/rtprocess.h 2004/10/23 18:55:52 3.11 @@ -1,4 +1,4 @@ -/* RCSid $Id: rtprocess.h,v 3.2 2003/06/27 06:53:21 greg Exp $ */ +/* RCSid $Id: rtprocess.h,v 3.11 2004/10/23 18:55:52 schorsch Exp $ */ /* * rtprocess.h * Routines to communicate with separate process via dual pipes @@ -7,40 +7,50 @@ */ #ifndef _RAD_PROCESS_H_ #define _RAD_PROCESS_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include +#include #ifdef _WIN32 - #include + #include /* DWORD etc. */ + #include + typedef DWORD RT_PID; + #include /* getpid() and others */ + #define nice(inc) win_nice(inc) + + #ifdef __cplusplus + extern "C" { + #endif + extern FILE *win_popen(char *command, char *type); + extern int win_pclose(FILE *p); + int win_kill(RT_PID pid, int sig /* ignored */); + #define kill(pid,sig) win_kill(pid,sig) + #ifdef __cplusplus + } + #endif + + #define popen(cmd,mode) win_popen(cmd,mode) + #define pclose(p) win_pclose(p) #else + #include #include - #include + #include + typedef pid_t RT_PID; #endif -#ifndef BSD -#include -#endif #include "paths.h" +#ifdef __cplusplus +extern "C" { +#endif /* On Windows, a process ID is a DWORD. That might actually be the same thing as an int, but it's better not to assume anything. This means that we shouldn't rely on PIDs and file descriptors being the same type, so we have to describe processes with a struct, - instead of the original int[3]. To keep things simple, we typedef - the posix pid_t on those systems that don't have it already. - - Some older Windows systems use negative PIDs. Open_process() and - close_process() will convert those to positive values during - runtime, so that client modules can still use -1 as invalid PID. + instead of the original int[3]. For that purpose, we typedef a + platform independent RT_PID. */ -#ifdef _WIN32 - typedef DWORD pid_t; -#endif #ifndef PIPE_BUF #ifdef PIPSIZ @@ -58,7 +68,7 @@ typedef struct { int r; /* read handle */ int w; /* write handle */ int running; /* doing something */ - pid_t pid; /* process ID */ + RT_PID pid; /* process ID */ } SUBPROC; #define SP_INACTIVE {-1,-1,0,0} /* for static initializations */ @@ -68,6 +78,11 @@ extern int close_process(SUBPROC *pd); extern int process(SUBPROC *pd, char *recvbuf, char *sendbuf, int nbr, int nbs); extern int readbuf(int fd, char *bpos, int siz); extern int writebuf(int fd, char *bpos, int siz); + +#ifdef _WIN32 +/* any non-negative increment will send the process to IDLE_PRIORITY_CLASS. */ +extern int win_nice(int inc); +#endif #ifdef __cplusplus