]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/pexecute.txh
pexecute.txh: Enclose multi-word data types in @deftypefn in braces.
[thirdparty/gcc.git] / libiberty / pexecute.txh
CommitLineData
2b836651 1@deftypefn Extension {struct pex_obj *} pex_init (int @var{flags}, const char *@var{pname}, const char *@var{tempbase})
55d0e5e0 2
a584cf65
ILT
3Prepare to execute one or more programs, with standard output of each
4program fed to standard input of the next. This is a system
5independent interface to execute a pipeline.
55d0e5e0 6
a584cf65 7@var{flags} is a bitwise combination of the following:
55d0e5e0 8
a584cf65 9@table @code
55d0e5e0 10
a584cf65
ILT
11@vindex PEX_RECORD_TIMES
12@item PEX_RECORD_TIMES
13Record subprocess times if possible.
55d0e5e0 14
a584cf65
ILT
15@vindex PEX_USE_PIPES
16@item PEX_USE_PIPES
17Use pipes for communication between processes, if possible.
55d0e5e0 18
a584cf65
ILT
19@vindex PEX_SAVE_TEMPS
20@item PEX_SAVE_TEMPS
21Don't delete temporary files used for communication between
22processes.
55d0e5e0 23
a584cf65 24@end table
55d0e5e0 25
a584cf65
ILT
26@var{pname} is the name of program to be executed, used in error
27messages. @var{tempbase} is a base name to use for any required
28temporary files; it may be @code{NULL} to use a randomly chosen name.
55d0e5e0
ZW
29
30@end deftypefn
31
2b836651 32@deftypefn Extension {const char *} pex_run (struct pex_obj *@var{obj}, int @var{flags}, const char *@var{executable}, char * const *@var{argv}, const char *@var{outname}, const char *@var{errname}, int *@var{err})
a584cf65
ILT
33
34Execute one program in a pipeline. On success this returns
35@code{NULL}. On failure it returns an error message, a statically
36allocated string.
37
38@var{obj} is returned by a previous call to @code{pex_init}.
39
40@var{flags} is a bitwise combination of the following:
41
42@table @code
43
44@vindex PEX_LAST
45@item PEX_LAST
46This must be set on the last program in the pipeline. In particular,
47it should be set when executing a single program. The standard output
48of the program will be sent to @var{outname}, or, if @var{outname} is
2b836651
EZ
49@code{NULL}, to the standard output of the calling program. Do @emph{not}
50set this bit if you want to call @code{pex_read_output}
a584cf65
ILT
51(described below). After a call to @code{pex_run} with this bit set,
52@var{pex_run} may no longer be called with the same @var{obj}.
53
54@vindex PEX_SEARCH
55@item PEX_SEARCH
56Search for the program using the user's executable search path.
57
58@vindex PEX_SUFFIX
59@item PEX_SUFFIX
60@var{outname} is a suffix. See the description of @var{outname},
61below.
62
63@vindex PEX_STDERR_TO_STDOUT
64@item PEX_STDERR_TO_STDOUT
65Send the program's standard error to standard output, if possible.
66
67@vindex PEX_BINARY_INPUT
68@vindex PEX_BINARY_OUTPUT
69@item PEX_BINARY_INPUT
70@itemx PEX_BINARY_OUTPUT
71The standard input (output) of the program should be read (written) in
72binary mode rather than text mode. These flags are ignored on systems
73which do not distinguish binary mode and text mode, such as Unix. For
2b836651 74proper behavior these flags should match appropriately---a call to
a584cf65
ILT
75@code{pex_run} using @code{PEX_BINARY_OUTPUT} should be followed by a
76call using @code{PEX_BINARY_INPUT}.
77@end table
78
79@var{executable} is the program to execute. @var{argv} is the set of
80arguments to pass to the program; normally @code{@var{argv}[0]} will
81be a copy of @var{executable}.
82
83@var{outname} is used to set the name of the file to use for standard
2b836651
EZ
84output. There are two cases in which no output file will be used:
85
86@enumerate
87@item
a584cf65 88if @code{PEX_LAST} is not set in @var{flags}, and @code{PEX_USE_PIPES}
2b836651
EZ
89was set in the call to @code{pex_init}, and the system supports pipes
90
91@item
92if @code{PEX_LAST} is set in @var{flags}, and @var{outname} is
93@code{NULL}
94@end enumerate
95
96@noindent
97Otherwise the code will use a file to hold standard
a584cf65
ILT
98output. If @code{PEX_LAST} is not set, this file is considered to be
99a temporary file, and it will be removed when no longer needed, unless
100@code{PEX_SAVE_TEMPS} was set in the call to @code{pex_init}.
101
102There are two cases to consider when setting the name of the file to
103hold standard output.
104
2b836651
EZ
105@enumerate
106@item
107@code{PEX_SUFFIX} is set in @var{flags}. In this case
a584cf65
ILT
108@var{outname} may not be @code{NULL}. If the @var{tempbase} parameter
109to @code{pex_init} was not @code{NULL}, then the output file name is
110the concatenation of @var{tempbase} and @var{outname}. If
111@var{tempbase} was @code{NULL}, then the output file name is a random
112file name ending in @var{outname}.
113
2b836651
EZ
114@item
115@code{PEX_SUFFIX} was not set in @var{flags}. In this
a584cf65
ILT
116case, if @var{outname} is not @code{NULL}, it is used as the output
117file name. If @var{outname} is @code{NULL}, and @var{tempbase} was
118not NULL, the output file name is randomly chosen using
119@var{tempbase}. Otherwise the output file name is chosen completely
120at random.
2b836651 121@end enumerate
a584cf65
ILT
122
123@var{errname} is the file name to use for standard error output. If
2b836651 124it is @code{NULL}, standard error is the same as the caller's.
a584cf65
ILT
125Otherwise, standard error is written to the named file.
126
127On an error return, the code sets @code{*@var{err}} to an @code{errno}
128value, or to 0 if there is no relevant @code{errno}.
129
130@end deftypefn
131
2b836651 132@deftypefn Extension {FILE *} pex_read_output (struct pex_obj *@var{obj}, int @var{binary})
a584cf65
ILT
133
134Returns a @code{FILE} pointer which may be used to read the standard
135output of the last program in the pipeline. When this is used,
136@code{PEX_LAST} should not be used in a call to @code{pex_run}. After
137this is called, @code{pex_run} may no longer be called with the same
138@var{obj}. @var{binary} should be non-zero if the file should be
139opened in binary mode. Don't call @code{fclose} on the returned file;
140it will be closed by @code{pex_free}.
141
142@end deftypefn
143
144@deftypefn Extension int pex_get_status (struct pex_obj *@var{obj}, int @var{count}, int *@var{vector})
145
146Returns the exit status of all programs run using @var{obj}.
147@var{count} is the number of results expected. The results will be
148placed into @var{vector}. The results are in the order of the calls
149to @code{pex_run}. Returns 0 on error, 1 on success.
150
151@end deftypefn
152
153@deftypefn Extension int pex_get_times (struct pex_obj *@var{obj}, int @var{count}, struct pex_time *@var{vector})
55d0e5e0 154
a584cf65
ILT
155Returns the process execution times of all programs run using
156@var{obj}. @var{count} is the number of results expected. The
157results will be placed into @var{vector}. The results are in the
158order of the calls to @code{pex_run}. Returns 0 on error, 1 on
159success.
55d0e5e0 160
2b836651
EZ
161@code{struct pex_time} has the following fields of the type
162@code{unsigned long}: @code{user_seconds},
a584cf65
ILT
163@code{user_microseconds}, @code{system_seconds},
164@code{system_microseconds}. On systems which do not support reporting
165process times, all the fields will be set to @code{0}.
55d0e5e0 166
a584cf65
ILT
167@end deftypefn
168
169@deftypefn Extension void pex_free (struct pex_obj @var{obj})
55d0e5e0 170
a584cf65 171Clean up and free all data associated with @var{obj}.
55d0e5e0
ZW
172
173@end deftypefn
174
2b836651 175@deftypefn Extension {const char *} pex_one (int @var{flags}, const char *@var{executable}, char * const *@var{argv}, const char *@var{pname}, const char *@var{outname}, const char *@var{errname}, int *@var{status}, int *@var{err})
a584cf65 176
2b836651 177An interface to permit the easy execution of a
a584cf65
ILT
178single program. The return value and most of the parameters are as
179for a call to @code{pex_run}. @var{flags} is restricted to a
180combination of @code{PEX_SEARCH}, @code{PEX_STDERR_TO_STDOUT}, and
181@code{PEX_BINARY_OUTPUT}. @var{outname} is interpreted as if
2b836651 182@code{PEX_LAST} were set. On a successful return, @code{*@var{status}} will
a584cf65
ILT
183be set to the exit status of the program.
184
185@end deftypefn
186
187@deftypefn Extension int pexecute (const char *@var{program}, char * const *@var{argv}, const char *@var{this_pname}, const char *@var{temp_base}, char **@var{errmsg_fmt}, char **@var{errmsg_arg}, int flags)
55d0e5e0 188
a584cf65
ILT
189This is the old interface to execute one or more programs. It is
190still supported for compatibility purposes, but is no longer
191documented.
55d0e5e0 192
a584cf65
ILT
193@end deftypefn
194
195@deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags})
196
197Another part of the old execution interface.
198
199@end deftypefn