ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/rtprocess.h
Revision: 3.1
Committed: Thu Jun 26 00:58:09 2003 UTC (20 years, 10 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Log Message:
Abstracted process and path handling for Windows.
Renamed FLOAT to RREAL because of conflict on Windows.
Added conditional compiles for some signal handlers.

File Contents

# Content
1 /* RCSid $Id$ */
2 /*
3 * rtprocess.h
4 * Routines to communicate with separate process via dual pipes
5 *
6 * WARNING: On Windows, there's a system header named <process.h>.
7 */
8 #ifndef _RAD_PROCESS_H_
9 #define _RAD_PROCESS_H_
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14
15 #include "copyright.h"
16
17 #include <sys/types.h>
18 #ifdef _WIN32
19 #include <windows.h>
20 #else
21 #include <sys/param.h>
22 #include <unistd.h>
23 #endif
24 #ifndef BSD
25 #include <errno.h>
26 #endif
27
28 #include "paths.h"
29
30
31 /* On Windows, a process ID is a DWORD. That might actually be the
32 same thing as an int, but it's better not to assume anything.
33
34 This means that we shouldn't rely on PIDs and file descriptors
35 being the same type, so we have to describe processes with a struct,
36 instead of the original int[3]. To keep things simple, we typedef
37 the posix pid_t on those systems that don't have it already.
38
39 Some older Windows systems use negative PIDs. Open_process() and
40 close_process() will convert those to positive values during
41 runtime, so that client modules can still use -1 as invalid PID.
42 */
43
44 #ifdef _WIN32
45 typedef DWORD pid_t;
46 #endif
47
48 #ifndef PIPE_BUF
49 #ifdef PIPSIZ
50 #define PIPE_BUF PIPSIZ
51 #else
52 #ifdef PIPE_MAX
53 #define PIPE_BUF PIPE_MAX
54 #else
55 #define PIPE_BUF 512 /* hyperconservative */
56 #endif
57 #endif
58 #endif
59
60 typedef struct {
61 int r; /* read handle */
62 int w; /* write handle */
63 int running; /* doing something */
64 pid_t pid; /* process ID */
65 } SUBPROC;
66
67 #define SP_INACTIVE {-1,-1,0,0} /* for static initializations */
68
69 extern int open_process(SUBPROC *pd, char *av[]);
70 extern int close_process(SUBPROC *pd);
71 extern int process(SUBPROC *pd, char *recvbuf, char *sendbuf, int nbr, int nbs);
72 extern int readbuf(int fd, char *bpos, int siz);
73 extern int writebuf(int fd, char *bpos, int siz);
74
75
76 #ifdef __cplusplus
77 }
78 #endif
79 #endif /* _RAD_PROCESS_H_ */
80