aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-14 16:13:07 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-14 16:13:07 +0200
commitfd069b4ca08cb46eb335a1434330b21fbaf84b9c (patch)
tree86596b5a361224322ea8ff23130273c835c25452
parent9d751e7eec4f4bc7292be46f2af774fe1adf336a (diff)
filter: pipe_fh should be local
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--cgit.h1
-rw-r--r--filter.c13
2 files changed, 7 insertions, 7 deletions
diff --git a/cgit.h b/cgit.h
index 0b88dcd..005ae63 100644
--- a/cgit.h
+++ b/cgit.h
@@ -71,7 +71,6 @@ struct cgit_exec_filter {
char *cmd;
char **argv;
int old_stdout;
- int pipe_fh[2];
int pid;
};
diff --git a/filter.c b/filter.c
index 949c931..70f5b74 100644
--- a/filter.c
+++ b/filter.c
@@ -42,6 +42,7 @@ void cgit_cleanup_filters(void)
static int open_exec_filter(struct cgit_filter *base, va_list ap)
{
struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base;
+ int pipe_fh[2];
int i;
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)
filter->old_stdout = chk_positive(dup(STDOUT_FILENO),
"Unable to duplicate STDOUT");
- chk_zero(pipe(filter->pipe_fh), "Unable to create pipe to subprocess");
+ chk_zero(pipe(pipe_fh), "Unable to create pipe to subprocess");
filter->pid = chk_non_negative(fork(), "Unable to create subprocess");
if (filter->pid == 0) {
- close(filter->pipe_fh[1]);
- chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO),
+ close(pipe_fh[1]);
+ chk_non_negative(dup2(pipe_fh[0], STDIN_FILENO),
"Unable to use pipe as STDIN");
execvp(filter->cmd, filter->argv);
die_errno("Unable to exec subprocess %s", filter->cmd);
}
- close(filter->pipe_fh[0]);
- chk_non_negative(dup2(filter->pipe_fh[1], STDOUT_FILENO),
+ close(pipe_fh[0]);
+ chk_non_negative(dup2(pipe_fh[1], STDOUT_FILENO),
"Unable to use pipe as STDOUT");
- close(filter->pipe_fh[1]);
+ close(pipe_fh[1]);
return 0;
}
202'>202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339