ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/rtprocess.h
Revision: 3.16
Committed: Sun Mar 6 01:13:17 2016 UTC (8 years, 2 months ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R1
Changes since 3.15: +5 -3 lines
Log Message:
Prepare for SCons build on Win32 and Win64

File Contents

# User Rev Content
1 schorsch 3.16 /* RCSid $Id: rtprocess.h,v 3.15 2016/03/04 02:48:14 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 greg 3.13 #include <stdio.h>
13 schorsch 3.16 #if defined(_WIN32) || defined(_WIN64)
14 schorsch 3.3 #include <windows.h> /* DWORD etc. */
15 schorsch 3.10 typedef DWORD RT_PID;
16 schorsch 3.3 #include <process.h> /* getpid() and others */
17 schorsch 3.16 #define getpid _getpid
18     #define execv _execv
19 schorsch 3.1 #else
20     #include <sys/param.h>
21 schorsch 3.10 #include <sys/types.h>
22     typedef pid_t RT_PID;
23 schorsch 3.1 #endif
24    
25     #include "paths.h"
26    
27 schorsch 3.4 #ifdef __cplusplus
28     extern "C" {
29     #endif
30 schorsch 3.1
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 schorsch 3.10 instead of the original int[3]. For that purpose, we typedef a
37     platform independent RT_PID.
38 schorsch 3.1 */
39    
40    
41     #ifndef PIPE_BUF
42     #ifdef PIPSIZ
43     #define PIPE_BUF PIPSIZ
44     #else
45     #ifdef PIPE_MAX
46     #define PIPE_BUF PIPE_MAX
47     #else
48     #define PIPE_BUF 512 /* hyperconservative */
49     #endif
50     #endif
51     #endif
52    
53     typedef struct {
54     int r; /* read handle */
55     int w; /* write handle */
56     int running; /* doing something */
57 schorsch 3.10 RT_PID pid; /* process ID */
58 schorsch 3.1 } SUBPROC;
59    
60     #define SP_INACTIVE {-1,-1,0,0} /* for static initializations */
61    
62 greg 3.15 #define close_process(pd) close_processes(pd,1)
63    
64 schorsch 3.1 extern int open_process(SUBPROC *pd, char *av[]);
65 greg 3.15 extern int close_processes(SUBPROC pd[], int nproc);
66 schorsch 3.1 extern int process(SUBPROC *pd, char *recvbuf, char *sendbuf, int nbr, int nbs);
67     extern int readbuf(int fd, char *bpos, int siz);
68     extern int writebuf(int fd, char *bpos, int siz);
69 schorsch 3.5
70 schorsch 3.16 #if defined(_WIN32) || defined(_WIN64)
71 schorsch 3.5 /* any non-negative increment will send the process to IDLE_PRIORITY_CLASS. */
72 greg 3.14 extern int win_kill(RT_PID pid, int sig /* ignored */);
73 schorsch 3.5 extern int win_nice(int inc);
74     #endif
75 schorsch 3.1
76    
77     #ifdef __cplusplus
78     }
79     #endif
80     #endif /* _RAD_PROCESS_H_ */
81