ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/rtprocess.h
Revision: 3.9
Committed: Fri Nov 14 17:22:06 2003 UTC (20 years, 11 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 3.8: +2 -1 lines
Log Message:
Reduced compile warnings, and other compatibility fixes.

File Contents

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