ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/rtprocess.h
(Generate patch)

Comparing ray/src/common/rtprocess.h (file contents):
Revision 3.13 by greg, Tue Feb 2 18:02:32 2016 UTC vs.
Revision 3.18 by greg, Fri Feb 28 05:18:49 2020 UTC

# Line 10 | Line 10
10  
11   #include  <errno.h>
12   #include <stdio.h>
13 < #ifdef _WIN32
13 > #if defined(_WIN32) || defined(_WIN64)
14    #include <windows.h> /* DWORD etc. */
15    typedef DWORD RT_PID;
16    #include <process.h> /* getpid() and others */
17 +  #define getpid _getpid
18 +  #define execv _execv
19 +  #define execvp _execvp
20   #else
21    #include <sys/param.h>
22    #include <sys/types.h>
# Line 35 | Line 38 | extern "C" {
38     platform independent RT_PID.
39   */
40  
41 + /* On Unix, we can set flags and assign descriptors before opening a
42 +   process, coupling an existing input or output to the new process rather
43 +   than opening both pipes.  If PF_FILT_INP is passed in the flags member of
44 +   SUBPROC, then the given r stream will be attached to the standard input
45 +   of the child process, and subsequent reads from that descriptor in the
46 +   parent get data from the standard output of the child, instead.  The
47 +   returned w descriptor is set to -1, since there is no longer any way
48 +   to write to the input of the child.  The default r descriptor of 0 will
49 +   compel the child to act as a filter on the standard input of the parent.
50 +   Whatever r handle you specify, the child will filter its read operations.
51 +   Note that this should be called before anything has been buffered using r.
52 +   If PF_FILT_OUT is set in flags, then the given w stream will be
53 +   attached to the standard output of the child, and subsequent writes
54 +   to that descriptor in the parent send data to the standard input
55 +   of the child. The returned r descriptor is set to -1, since
56 +   there is no output to read from any longer in the child.  The
57 +   default w descriptor of 1 will cause the child to act as a filter
58 +   on the output of the parent.  Make sure to call fflush(stdout) first
59 +   if any data was buffered.  It is illegal to set both PF_FILT_INP and
60 +   PF_FILT_OUT, as a circular process is guaranteed to hang.
61 + */
62  
63 +
64   #ifndef PIPE_BUF
65    #ifdef PIPSIZ
66      #define PIPE_BUF    PIPSIZ
# Line 47 | Line 72 | extern "C" {
72      #endif
73    #endif
74   #endif
75 +                                /* process flags */
76 + #define PF_RUNNING      1               /* process is running */
77 + #define PF_FILT_INP     2               /* use assigned read descriptor */
78 + #define PF_FILT_OUT     4               /* use assigned write descriptor */
79  
80   typedef struct {
81 <        int r; /* read handle */
82 <        int w; /* write handle */
83 <        int running; /* doing something */
84 <        RT_PID pid; /* process ID */
81 >        int     flags;          /* what is being done */
82 >        int     r;              /* read handle */
83 >        int     w;              /* write handle */
84 >        RT_PID  pid;            /* process ID */
85   } SUBPROC;
86  
87 < #define SP_INACTIVE {-1,-1,0,0} /* for static initializations */
87 > #define SP_INACTIVE {0,0,1,-1}  /* for static initializations */
88  
89 + #define close_process(pd)       close_processes(pd,1)
90 +
91   extern int open_process(SUBPROC *pd, char *av[]);
92 < extern int close_process(SUBPROC *pd);
92 > extern int close_processes(SUBPROC pd[], int nproc);
93   extern int process(SUBPROC *pd, char *recvbuf, char *sendbuf, int nbr, int nbs);
94   extern int readbuf(int fd, char *bpos, int siz);
95   extern int writebuf(int fd, char *bpos, int siz);
96  
97 < #ifdef _WIN32
97 > #if defined(_WIN32) || defined(_WIN64)
98   /* any non-negative increment will send the process to IDLE_PRIORITY_CLASS. */
99 + extern int win_kill(RT_PID pid, int sig /* ignored */);
100   extern int win_nice(int inc);
101   #endif
102  
103 + extern SUBPROC  sp_inactive;
104  
105   #ifdef __cplusplus
106   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines