diff options
Diffstat (limited to 'filter.c')
-rw-r--r-- | filter.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -106,7 +106,7 @@ static int open_exec_filter(struct cgit_filter *base, va_list ap) | |||
106 | static int close_exec_filter(struct cgit_filter *base) | 106 | static int close_exec_filter(struct cgit_filter *base) |
107 | { | 107 | { |
108 | struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base; | 108 | struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base; |
109 | int i, exit_status; | 109 | int i, exit_status = 0; |
110 | 110 | ||
111 | chk_non_negative(dup2(filter->old_stdout, STDOUT_FILENO), | 111 | chk_non_negative(dup2(filter->old_stdout, STDOUT_FILENO), |
112 | "Unable to restore STDOUT"); | 112 | "Unable to restore STDOUT"); |
@@ -114,14 +114,14 @@ static int close_exec_filter(struct cgit_filter *base) | |||
114 | if (filter->pid < 0) | 114 | if (filter->pid < 0) |
115 | goto done; | 115 | goto done; |
116 | waitpid(filter->pid, &exit_status, 0); | 116 | waitpid(filter->pid, &exit_status, 0); |
117 | if (WIFEXITED(exit_status) && !WEXITSTATUS(exit_status)) | 117 | if (WIFEXITED(exit_status)) |
118 | goto done; | 118 | goto done; |
119 | die("Subprocess %s exited abnormally", filter->cmd); | 119 | die("Subprocess %s exited abnormally", filter->cmd); |
120 | 120 | ||
121 | done: | 121 | done: |
122 | for (i = 0; i < filter->base.argument_count; i++) | 122 | for (i = 0; i < filter->base.argument_count; i++) |
123 | filter->argv[i + 1] = NULL; | 123 | filter->argv[i + 1] = NULL; |
124 | return 0; | 124 | return WEXITSTATUS(exit_status); |
125 | 125 | ||
126 | } | 126 | } |
127 | 127 | ||
@@ -315,10 +315,14 @@ static int close_lua_filter(struct cgit_filter *base) | |||
315 | int ret = 0; | 315 | int ret = 0; |
316 | 316 | ||
317 | lua_getglobal(filter->lua_state, "filter_close"); | 317 | lua_getglobal(filter->lua_state, "filter_close"); |
318 | if (lua_pcall(filter->lua_state, 0, 0, 0)) { | 318 | if (lua_pcall(filter->lua_state, 0, 1, 0)) { |
319 | error_lua_filter(filter); | 319 | error_lua_filter(filter); |
320 | ret = 1; | 320 | ret = -1; |
321 | } else { | ||
322 | ret = lua_tonumber(filter->lua_state, -1); | ||
323 | lua_pop(filter->lua_state, 1); | ||
321 | } | 324 | } |
325 | |||
322 | unhook_write(); | 326 | unhook_write(); |
323 | return ret; | 327 | return ret; |
324 | } | 328 | } |