ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/rtprocess.h
Revision: 3.12
Committed: Tue Mar 4 17:06:13 2014 UTC (10 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad4R2P2, rad5R0, rad4R2, rad4R2P1
Changes since 3.11: +8 -4 lines
Log Message:
Changed to using _popen and _pclose under MicroSoft VisualStudio

File Contents

# Content
1 /* RCSid $Id: rtprocess.h,v 3.11 2004/10/23 18:55:52 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 #include <stdio.h>
15 typedef DWORD RT_PID;
16 #include <process.h> /* getpid() and others */
17 #define nice(inc) win_nice(inc)
18
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 int win_kill(RT_PID pid, int sig /* ignored */);
25 #define kill(pid,sig) win_kill(pid,sig)
26 #ifdef __cplusplus
27 }
28 #endif
29 #ifdef _MSC_VER
30 #define popen(cmd,mode) _popen(cmd,mode)
31 #define pclose(p) _pclose(p)
32 #else
33 #define popen(cmd,mode) win_popen(cmd,mode)
34 #define pclose(p) win_pclose(p)
35 #endif
36 #else
37 #include <stdio.h>
38 #include <sys/param.h>
39 #include <sys/types.h>
40 typedef pid_t RT_PID;
41 #endif
42
43 #include "paths.h"
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 /* On Windows, a process ID is a DWORD. That might actually be the
50 same thing as an int, but it's better not to assume anything.
51
52 This means that we shouldn't rely on PIDs and file descriptors
53 being the same type, so we have to describe processes with a struct,
54 instead of the original int[3]. For that purpose, we typedef a
55 platform independent RT_PID.
56 */
57
58
59 #ifndef PIPE_BUF
60 #ifdef PIPSIZ
61 #define PIPE_BUF PIPSIZ
62 #else
63 #ifdef PIPE_MAX
64 #define PIPE_BUF PIPE_MAX
65 #else
66 #define PIPE_BUF 512 /* hyperconservative */
67 #endif
68 #endif
69 #endif
70
71 typedef struct {
72 int r; /* read handle */
73 int w; /* write handle */
74 int running; /* doing something */
75 RT_PID pid; /* process ID */
76 } SUBPROC;
77
78 #define SP_INACTIVE {-1,-1,0,0} /* for static initializations */
79
80 extern int open_process(SUBPROC *pd, char *av[]);
81 extern int close_process(SUBPROC *pd);
82 extern int process(SUBPROC *pd, char *recvbuf, char *sendbuf, int nbr, int nbs);
83 extern int readbuf(int fd, char *bpos, int siz);
84 extern int writebuf(int fd, char *bpos, int siz);
85
86 #ifdef _WIN32
87 /* any non-negative increment will send the process to IDLE_PRIORITY_CLASS. */
88 extern int win_nice(int inc);
89 #endif
90
91
92 #ifdef __cplusplus
93 }
94 #endif
95 #endif /* _RAD_PROCESS_H_ */
96