]> git.ozlabs.org Git - ccan/blob - ccan/pipecmd/pipecmd.h
87e3dcf8193ddf17985f0c33d372be34928566f6
[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  * @cmd...: NULL-terminate list of command and arguments.
14  *
15  * If @infd is NULL, the child's input is (read-only) /dev/null.
16  * If @outfd is NULL, the child's output is (write-only) /dev/null.
17  *
18  * The return value is the pid of the child, or -1.
19  */
20 pid_t pipecmd(int *infd, int *outfd, const char *cmd, ...);
21
22 /**
23  * pipecmdv - run a command, optionally connect pipes (stdarg version)
24  * @infd: input fd to write to child (if non-NULL)
25  * @outfd: output fd to read from child (if non-NULL)
26  * @cmd: command to run.
27  * @ap: argument list for arguments.
28  */
29 pid_t pipecmdv(int *infd, int *outfd, const char *cmd, va_list ap);
30
31 /**
32  * pipecmdarr - run a command, optionally connect pipes (char arry version)
33  * @infd: input fd to write to child (if non-NULL)
34  * @outfd: output fd to read from child (if non-NULL)
35  * @arr: NULL-terminated array for arguments (first is program to run).
36  */
37 pid_t pipecmdarr(int *infd, int *outfd, char *const *arr);
38 #endif /* CCAN_PIPECMD_H */