ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/rtprocess.h
Revision: 3.15
Committed: Fri Mar 4 02:48:14 2016 UTC (8 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 3.14: +4 -2 lines
Log Message:
Made quitting rvu, rholo and rcontrib quicker with multiple processes on Unix

File Contents

# User Rev Content
1 greg 3.15 /* RCSid $Id: rtprocess.h,v 3.14 2016/02/03 22:41:35 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.1 #ifdef _WIN32
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.1 #else
18     #include <sys/param.h>
19 schorsch 3.10 #include <sys/types.h>
20     typedef pid_t RT_PID;
21 schorsch 3.1 #endif
22    
23     #include "paths.h"
24    
25 schorsch 3.4 #ifdef __cplusplus
26     extern "C" {
27     #endif
28 schorsch 3.1
29     /* On Windows, a process ID is a DWORD. That might actually be the
30     same thing as an int, but it's better not to assume anything.
31    
32     This means that we shouldn't rely on PIDs and file descriptors
33     being the same type, so we have to describe processes with a struct,
34 schorsch 3.10 instead of the original int[3]. For that purpose, we typedef a
35     platform independent RT_PID.
36 schorsch 3.1 */
37    
38    
39     #ifndef PIPE_BUF
40     #ifdef PIPSIZ
41     #define PIPE_BUF PIPSIZ
42     #else
43     #ifdef PIPE_MAX
44     #define PIPE_BUF PIPE_MAX
45     #else
46     #define PIPE_BUF 512 /* hyperconservative */
47     #endif
48     #endif
49     #endif
50    
51     typedef struct {
52     int r; /* read handle */
53     int w; /* write handle */
54     int running; /* doing something */
55 schorsch 3.10 RT_PID pid; /* process ID */
56 schorsch 3.1 } SUBPROC;
57    
58     #define SP_INACTIVE {-1,-1,0,0} /* for static initializations */
59    
60 greg 3.15 #define close_process(pd) close_processes(pd,1)
61    
62 schorsch 3.1 extern int open_process(SUBPROC *pd, char *av[]);
63 greg 3.15 extern int close_processes(SUBPROC pd[], int nproc);
64 schorsch 3.1 extern int process(SUBPROC *pd, char *recvbuf, char *sendbuf, int nbr, int nbs);
65     extern int readbuf(int fd, char *bpos, int siz);
66     extern int writebuf(int fd, char *bpos, int siz);
67 schorsch 3.5
68     #ifdef _WIN32
69     /* any non-negative increment will send the process to IDLE_PRIORITY_CLASS. */
70 greg 3.14 extern int win_kill(RT_PID pid, int sig /* ignored */);
71 schorsch 3.5 extern int win_nice(int inc);
72     #endif
73 schorsch 3.1
74    
75     #ifdef __cplusplus
76     }
77     #endif
78     #endif /* _RAD_PROCESS_H_ */
79