X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=run-command.h;h=44f7d2bd42ddcf2d65722b7e54bea69645d167a2;hb=87cb3b82a42613dc3ffd1eddf95f8c306a045ad1;hp=5203a9ebb10b14bd06862abafed0ab73d7514a3d;hpb=4d9e42f8f11c57b32b976a943c8ddaf6214e64b8;p=git.git diff --git a/run-command.h b/run-command.h index 5203a9ebb..44f7d2bd4 100644 --- a/run-command.h +++ b/run-command.h @@ -1,15 +1,9 @@ #ifndef RUN_COMMAND_H #define RUN_COMMAND_H -enum { - ERR_RUN_COMMAND_FORK = 10000, - ERR_RUN_COMMAND_EXEC, - ERR_RUN_COMMAND_PIPE, - ERR_RUN_COMMAND_WAITPID, - ERR_RUN_COMMAND_WAITPID_WRONG_PID, - ERR_RUN_COMMAND_WAITPID_SIGNAL, - ERR_RUN_COMMAND_WAITPID_NOEXIT, -}; +#ifndef NO_PTHREADS +#include +#endif struct child_process { const char **argv; @@ -28,7 +22,7 @@ struct child_process { * - Specify > 0 to set a channel to a particular FD as follows: * .in: a readable FD, becomes child's stdin * .out: a writable FD, becomes child's stdout/stderr - * .err > 0 not supported + * .err: a writable FD, becomes child's stderr * The specified FD is closed by start_command(), even in case * of errors! */ @@ -41,18 +35,26 @@ struct child_process { unsigned no_stdout:1; unsigned no_stderr:1; unsigned git_cmd:1; /* if this is to be git sub-command */ + unsigned silent_exec_failure:1; unsigned stdout_to_stderr:1; + unsigned use_shell:1; + unsigned clean_on_exit:1; + void (*preexec_cb)(void); }; int start_command(struct child_process *); int finish_command(struct child_process *); int run_command(struct child_process *); +extern int run_hook(const char *index_file, const char *name, ...); + #define RUN_COMMAND_NO_STDIN 1 #define RUN_GIT_CMD 2 /*If this is to be git sub-command */ #define RUN_COMMAND_STDOUT_TO_STDERR 4 +#define RUN_SILENT_EXEC_FAILURE 8 +#define RUN_USING_SHELL 16 +#define RUN_CLEAN_ON_EXIT 32 int run_command_v_opt(const char **argv, int opt); -int run_command_v_opt_cd(const char **argv, int opt, const char *dir); /* * env (the environment) is to be formatted like environ: "VAR=VALUE". @@ -70,17 +72,20 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const */ struct async { /* - * proc writes to fd and closes it; + * proc reads from in; closes it before return + * proc writes to out; closes it before return * returns 0 on success, non-zero on failure */ - int (*proc)(int fd, void *data); + int (*proc)(int in, int out, void *data); void *data; + int in; /* caller writes here and closes it */ int out; /* caller reads from here and closes it */ -#ifndef __MINGW32__ +#ifdef NO_PTHREADS pid_t pid; #else - HANDLE tid; - int fd_for_proc; + pthread_t tid; + int proc_in; + int proc_out; #endif };