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 |
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 |
|
|
100 |
|
extern int win_nice(int inc); |
101 |
|
#endif |
102 |
|
|
103 |
+ |
extern SUBPROC sp_inactive; |
104 |
|
|
105 |
|
#ifdef __cplusplus |
106 |
|
} |