]> git.ozlabs.org Git - ccan/blob - ccan/pipecmd/pipecmd.h
pipecmd: add stderr fd arg.
[ccan] / ccan / pipecmd / pipecmd.h
1 /* CC0 license (public domain) - see LICENSE file for details */
2 #ifndef CCAN_PIPECMD_H
3 #define CCAN_PIPECMD_H
4 #include "config.h"
5 #include <sys/types.h>
6 #include <sys/wait.h>
7 #include <stdarg.h>
8
9 /**
10  * pipecmd - run a command, optionally connect pipes.
11  * @infd: input fd to write to child (if non-NULL)
12  * @outfd: output fd to read from child (if non-NULL)
13  * @errfd: error-output fd to read from child (if non-NULL)
14  * @cmd...: NULL-terminate list of command and arguments.
15  *
16  * If @infd is NULL, the child's input is (read-only) /dev/null.
17  * If @outfd is NULL, the child's output is (write-only) /dev/null.
18  * If @errfd is NULL, the child's stderr is (write-only) /dev/null.
19  *
20  * If @errfd == @outfd (and non-NULL) they will be shared.
21  *
22  * The return value is the pid of the child, or -1.
23  */
24 pid_t pipecmd(int *infd, int *outfd, int *errfd, const char *cmd, ...);
25
26 /**
27  * pipecmdv - run a command, optionally connect pipes (stdarg version)
28  * @infd: input fd to write to child (if non-NULL)
29  * @outfd: output fd to read from child (if non-NULL)
30  * @errfd: error-output fd to read from child (if non-NULL)
31  * @cmd: command to run.
32  * @ap: argument list for arguments.
33  */
34 pid_t pipecmdv(int *infd, int *outfd, int *errfd, const char *cmd, va_list ap);
35
36 /**
37  * pipecmdarr - run a command, optionally connect pipes (char arry version)
38  * @infd: input fd to write to child (if non-NULL)
39  * @outfd: output fd to read from child (if non-NULL)
40  * @errfd: error-output fd to read from child (if non-NULL)
41  * @arr: NULL-terminated array for arguments (first is program to run).
42  */
43 pid_t pipecmdarr(int *infd, int *outfd, int *errfd, char *const *arr);
44 #endif /* CCAN_PIPECMD_H */