]> git.ozlabs.org Git - ccan/blob - ccan/pipecmd/pipecmd.h
base64: fix for unsigned chars (e.g. ARM).
[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  * If @infd, @outfd or @errfd is &pipecmd_preserve, it is unchanged.
22  *
23  * The return value is the pid of the child, or -1.  All other file-descriptors
24  * are closed in the child.
25  */
26 pid_t pipecmd(int *infd, int *outfd, int *errfd, const char *cmd, ...);
27
28 /**
29  * pipecmdv - run a command, optionally connect pipes (stdarg version)
30  * @infd: input fd to write to child (if non-NULL)
31  * @outfd: output fd to read from child (if non-NULL)
32  * @errfd: error-output fd to read from child (if non-NULL)
33  * @cmd: command to run.
34  * @ap: argument list for arguments.
35  */
36 pid_t pipecmdv(int *infd, int *outfd, int *errfd, const char *cmd, va_list ap);
37
38 /**
39  * pipecmdarr - run a command, optionally connect pipes (char arry version)
40  * @infd: input fd to write to child (if non-NULL)
41  * @outfd: output fd to read from child (if non-NULL)
42  * @errfd: error-output fd to read from child (if non-NULL)
43  * @arr: NULL-terminated array for arguments (first is program to run).
44  */
45 pid_t pipecmdarr(int *infd, int *outfd, int *errfd, char *const *arr);
46
47 /**
48  * pipecmd_preserve - special value for fds to indicate it is unchanged
49  */
50 extern int pipecmd_preserve;
51
52 #endif /* CCAN_PIPECMD_H */