merge from gcc
[deliverable/binutils-gdb.git] / libiberty / pexecute.txh
CommitLineData
5a17353c
DD
1@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)
2
3Executes a program.
4
5@var{program} and @var{argv} are the arguments to
6@code{execv}/@code{execvp}.
7
8@var{this_pname} is name of the calling program (i.e., @code{argv[0]}).
9
10@var{temp_base} is the path name, sans suffix, of a temporary file to
11use if needed. This is currently only needed for MS-DOS ports that
12don't use @code{go32} (do any still exist?). Ports that don't need it
13can pass @code{NULL}.
14
15(@code{@var{flags} & PEXECUTE_SEARCH}) is non-zero if @env{PATH}
16should be searched (??? It's not clear that GCC passes this flag
17correctly). (@code{@var{flags} & PEXECUTE_FIRST}) is nonzero for the
18first process in chain. (@code{@var{flags} & PEXECUTE_FIRST}) is
19nonzero for the last process in chain. The first/last flags could be
20simplified to only mark the last of a chain of processes but that
21requires the caller to always mark the last one (and not give up
22early if some error occurs). It's more robust to require the caller
23to mark both ends of the chain.
24
25The result is the pid on systems like Unix where we
26@code{fork}/@code{exec} and on systems like WIN32 and OS/2 where we
27use @code{spawn}. It is up to the caller to wait for the child.
28
29The result is the @code{WEXITSTATUS} on systems like MS-DOS where we
30@code{spawn} and wait for the child here.
31
32Upon failure, @var{errmsg_fmt} and @var{errmsg_arg} are set to the
33text of the error message with an optional argument (if not needed,
34@var{errmsg_arg} is set to @code{NULL}), and @minus{}1 is returned.
35@code{errno} is available to the caller to use.
36
37@end deftypefn
38
39@deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags})
40
41Waits for a program started by @code{pexecute} to finish.
42
43@var{pid} is the process id of the task to wait for. @var{status} is
44the `status' argument to wait. @var{flags} is currently unused
45(allows future enhancement without breaking upward compatibility).
46Pass 0 for now.
47
48The result is the pid of the child reaped, or -1 for failure
49(@code{errno} says why).
50
51On systems that don't support waiting for a particular child,
52@var{pid} is ignored. On systems like MS-DOS that don't really
53multitask @code{pwait} is just a mechanism to provide a consistent
54interface for the caller.
55
56@end deftypefn
57
58@undocumented pfinish
59
60pfinish: finish generation of script
61
62pfinish is necessary for systems like MPW where a script is generated
63that runs the requested programs.
This page took 0.025278 seconds and 4 git commands to generate.