ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/rtprocess.h
Revision: 3.5
Committed: Tue Oct 21 19:19:28 2003 UTC (20 years, 6 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 3.4: +7 -5 lines
Log Message:
Various platform compatibility fixes.

File Contents

# Content
1 /* RCSid $Id: rtprocess.h,v 3.4 2003/07/14 22:23:59 schorsch Exp $ */
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
11 #include <errno.h>
12 #ifdef _WIN32
13 #include <windows.h> /* DWORD etc. */
14 typedef DWORD pid_t;
15 #include <process.h> /* getpid() and others */
16 #define nice(inc) win_nice(inc)
17 #else
18 #include <sys/param.h>
19 #endif
20
21 #include "paths.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /* On Windows, a process ID is a DWORD. That might actually be the
28 same thing as an int, but it's better not to assume anything.
29
30 This means that we shouldn't rely on PIDs and file descriptors
31 being the same type, so we have to describe processes with a struct,
32 instead of the original int[3]. To keep things simple, we typedef
33 the posix pid_t on those systems that don't have it already.
34 */
35
36
37 #ifndef PIPE_BUF
38 #ifdef PIPSIZ
39 #define PIPE_BUF PIPSIZ
40 #else
41 #ifdef PIPE_MAX
42 #define PIPE_BUF PIPE_MAX
43 #else
44 #define PIPE_BUF 512 /* hyperconservative */
45 #endif
46 #endif
47 #endif
48
49 typedef struct {
50 int r; /* read handle */
51 int w; /* write handle */
52 int running; /* doing something */
53 pid_t pid; /* process ID */
54 } SUBPROC;
55
56 #define SP_INACTIVE {-1,-1,0,0} /* for static initializations */
57
58 extern int open_process(SUBPROC *pd, char *av[]);
59 extern int close_process(SUBPROC *pd);
60 extern int process(SUBPROC *pd, char *recvbuf, char *sendbuf, int nbr, int nbs);
61 extern int readbuf(int fd, char *bpos, int siz);
62 extern int writebuf(int fd, char *bpos, int siz);
63
64 #ifdef _WIN32
65 /* any non-negative increment will send the process to IDLE_PRIORITY_CLASS. */
66 extern int win_nice(int inc);
67 #endif
68
69
70 #ifdef __cplusplus
71 }
72 #endif
73 #endif /* _RAD_PROCESS_H_ */
74