diff options
| -rw-r--r-- | cgit.h | 1 | ||||
| -rw-r--r-- | filter.c | 13 |
2 files changed, 7 insertions, 7 deletions
| @@ -71,7 +71,6 @@ struct cgit_exec_filter { | |||
| 71 | char *cmd; | 71 | char *cmd; |
| 72 | char **argv; | 72 | char **argv; |
| 73 | int old_stdout; | 73 | int old_stdout; |
| 74 | int pipe_fh[2]; | ||
| 75 | int pid; | 74 | int pid; |
| 76 | }; | 75 | }; |
| 77 | 76 | ||
| @@ -42,6 +42,7 @@ void cgit_cleanup_filters(void) | |||
| 42 | static int open_exec_filter(struct cgit_filter *base, va_list ap) | 42 | static int open_exec_filter(struct cgit_filter *base, va_list ap) |
| 43 | { | 43 | { |
| 44 | struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base; | 44 | struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base; |
| 45 | int pipe_fh[2]; | ||
| 45 | int i; | 46 | int i; |
| 46 | 47 | ||
| 47 | for (i = 0; i < filter->base.argument_count; i++) | 48 | for (i = 0; i < filter->base.argument_count; i++) |
| @@ -49,19 +50,19 @@ static int open_exec_filter(struct cgit_filter *base, va_list ap) | |||
| 49 | 50 | ||
| 50 | filter->old_stdout = chk_positive(dup(STDOUT_FILENO), | 51 | filter->old_stdout = chk_positive(dup(STDOUT_FILENO), |
| 51 | "Unable to duplicate STDOUT"); | 52 | "Unable to duplicate STDOUT"); |
| 52 | chk_zero(pipe(filter->pipe_fh), "Unable to create pipe to subprocess"); | 53 | chk_zero(pipe(pipe_fh), "Unable to create pipe to subprocess"); |
| 53 | filter->pid = chk_non_negative(fork(), "Unable to create subprocess"); | 54 | filter->pid = chk_non_negative(fork(), "Unable to create subprocess"); |
| 54 | if (filter->pid == 0) { | 55 | if (filter->pid == 0) { |
| 55 | close(filter->pipe_fh[1]); | 56 | close(pipe_fh[1]); |
| 56 | chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO), | 57 | chk_non_negative(dup2(pipe_fh[0], STDIN_FILENO), |
| 57 | "Unable to use pipe as STDIN"); | 58 | "Unable to use pipe as STDIN"); |
| 58 | execvp(filter->cmd, filter->argv); | 59 | execvp(filter->cmd, filter->argv); |
| 59 | die_errno("Unable to exec subprocess %s", filter->cmd); | 60 | die_errno("Unable to exec subprocess %s", filter->cmd); |
| 60 | } | 61 | } |
| 61 | close(filter->pipe_fh[0]); | 62 | close(pipe_fh[0]); |
| 62 | chk_non_negative(dup2(filter->pipe_fh[1], STDOUT_FILENO), | 63 | chk_non_negative(dup2(pipe_fh[1], STDOUT_FILENO), |
| 63 | "Unable to use pipe as STDOUT"); | 64 | "Unable to use pipe as STDOUT"); |
| 64 | close(filter->pipe_fh[1]); | 65 | close(pipe_fh[1]); |
| 65 | return 0; | 66 | return 0; |
| 66 | } | 67 | } |
| 67 | 68 | ||
