* New alpha version 2.24.1
[alpine.git] / pith / osdep / pipe.h
blob9b408e093d50c5e492db1d7b97d294058d300fca
1 /*
2 * $Id: pipe.h 769 2007-10-24 00:15:40Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2013-2021 Eduardo Chappa
6 * Copyright 2006 University of Washington
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * ========================================================================
17 #ifndef PITH_OSDEP_PIPE_INCLUDED
18 #define PITH_OSDEP_PIPE_INCLUDED
20 /* Standard I/O File Descriptor Definitions */
21 #ifndef STDIN_FILENO
22 #define STDIN_FILENO 0
23 #endif
24 #ifndef STDOUT_FILENO
25 #define STDOUT_FILENO 1
26 #endif
27 #ifndef STDERR_FILENO
28 #define STDERR_FILENO 2
29 #endif
33 * Flags for the pipe command routines...
35 #define PIPE_WRITE 0x0001 /* set up pipe for reading */
36 #define PIPE_READ 0x0002 /* set up pipe for reading */
37 #define PIPE_NOSHELL 0x0004 /* don't exec in shell */
38 #define PIPE_USER 0x0008 /* user mode */
39 #define PIPE_STDERR 0x0010 /* stderr to child output */
40 #define PIPE_PROT 0x0020 /* protected mode */
41 #define PIPE_RESET 0x0040 /* reset terminal mode */
42 #define PIPE_DESC 0x0080 /* no stdio desc wrapping */
43 #define PIPE_SILENT 0x0100 /* no screen clear, etc */
44 #define PIPE_RUNNOW 0x0200 /* don't wait for child (PC-Pine) */
45 #define PIPE_RAW 0x0400 /* don't convert to locale */
46 #define PIPE_NONEWMAIL 0x0800 /* don't call new_mail */
48 #ifdef _WINDOWS
50 * Flags for mswin_exec_and_wait
52 #define MSWIN_EAW_CAPT_STDERR 0x0001
53 #define MSWIN_EAW_CTRL_C_CANCELS 0x0002
54 #endif
58 * Reaper flags
60 #define PR_NONE 0x0000
61 #ifdef WNOHANG
62 #define PR_NOHANG 0x0001
63 #endif
66 * open_system_pipe callback so caller can insert code, typically interface
67 * stuff right before/after the fork and before/after wait
69 #define OSB_PRE_OPEN 0x0001
70 #define OSB_POST_OPEN 0x0002
71 #define OSB_PRE_CLOSE 0x0004
72 #define OSB_POST_CLOSE 0x0008
75 * structure required for the pipe commands...
77 typedef struct pipe_s {
78 pid_t pid; /* child's process id */
79 int mode, /* mode flags used to open */
80 timeout, /* wait this long for child */
81 old_timeo; /* previous active alarm */
82 RETSIGTYPE (*hsig)(int), /* previously installed... */
83 (*isig)(int), /* handlers */
84 (*qsig)(int),
85 (*alrm)(int),
86 (*chld)(int);
87 union {
88 FILE *f;
89 int d;
90 } in; /* input data handle */
91 union {
92 FILE *f;
93 int d;
94 } out; /* output data handle */
95 char **argv, /* any necessary args */
96 *args,
97 *tmp; /* pointer to stuff */
98 #ifdef _WINDOWS
99 char *infile; /* file containing pipe's stdin */
100 char *outfile; /* file containing pipe's stdout */
101 char *command; /* command to execute */
102 int exit_code; /* proc rv if run right away */
103 int deloutfile; /* need to rm outfile at close */
104 #endif
105 } PIPE_S;
109 * Exported Prototypes
111 PIPE_S *open_system_pipe(char *, char **, char **, int, int,
112 void (*)(PIPE_S *, int, void *), void (*)(char *));
113 int close_system_pipe(PIPE_S **, int *, void (*)(PIPE_S *, int, void *));
114 int pipe_close_write(PIPE_S *);
115 pid_t process_reap(pid_t, int *, int);
118 #endif /* PITH_OSDEP_PIPE_INCLUDED */