~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/lib/subcmd/run-command.h

Version: ~ [ linux-5.15-rc5 ] ~ [ linux-5.14.11 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.72 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.152 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.210 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.250 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.286 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.288 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __SUBCMD_RUN_COMMAND_H
  3 #define __SUBCMD_RUN_COMMAND_H
  4 
  5 #include <unistd.h>
  6 
  7 enum {
  8         ERR_RUN_COMMAND_FORK = 10000,
  9         ERR_RUN_COMMAND_EXEC,
 10         ERR_RUN_COMMAND_PIPE,
 11         ERR_RUN_COMMAND_WAITPID,
 12         ERR_RUN_COMMAND_WAITPID_WRONG_PID,
 13         ERR_RUN_COMMAND_WAITPID_SIGNAL,
 14         ERR_RUN_COMMAND_WAITPID_NOEXIT,
 15 };
 16 #define IS_RUN_COMMAND_ERR(x) (-(x) >= ERR_RUN_COMMAND_FORK)
 17 
 18 struct child_process {
 19         const char **argv;
 20         pid_t pid;
 21         /*
 22          * Using .in, .out, .err:
 23          * - Specify 0 for no redirections (child inherits stdin, stdout,
 24          *   stderr from parent).
 25          * - Specify -1 to have a pipe allocated as follows:
 26          *     .in: returns the writable pipe end; parent writes to it,
 27          *          the readable pipe end becomes child's stdin
 28          *     .out, .err: returns the readable pipe end; parent reads from
 29          *          it, the writable pipe end becomes child's stdout/stderr
 30          *   The caller of start_command() must close the returned FDs
 31          *   after it has completed reading from/writing to it!
 32          * - Specify > 0 to set a channel to a particular FD as follows:
 33          *     .in: a readable FD, becomes child's stdin
 34          *     .out: a writable FD, becomes child's stdout/stderr
 35          *     .err > 0 not supported
 36          *   The specified FD is closed by start_command(), even in case
 37          *   of errors!
 38          */
 39         int in;
 40         int out;
 41         int err;
 42         const char *dir;
 43         const char *const *env;
 44         unsigned no_stdin:1;
 45         unsigned no_stdout:1;
 46         unsigned no_stderr:1;
 47         unsigned exec_cmd:1; /* if this is to be external sub-command */
 48         unsigned stdout_to_stderr:1;
 49         void (*preexec_cb)(void);
 50 };
 51 
 52 int start_command(struct child_process *);
 53 int finish_command(struct child_process *);
 54 int run_command(struct child_process *);
 55 
 56 #define RUN_COMMAND_NO_STDIN 1
 57 #define RUN_EXEC_CMD         2  /*If this is to be external sub-command */
 58 #define RUN_COMMAND_STDOUT_TO_STDERR 4
 59 int run_command_v_opt(const char **argv, int opt);
 60 
 61 #endif /* __SUBCMD_RUN_COMMAND_H */
 62 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp