degesch: avoid fileno() after fork()

It's not guaranteed to be async-signal-safe, which may matter once
we start using threads. And it's also cleaner to just pass the FD.
This commit is contained in:
Přemysl Eric Janouch 2015-12-31 03:46:06 +01:00
parent b4d6decc06
commit 8f229f41e1
1 changed files with 4 additions and 4 deletions

View File

@ -10484,13 +10484,13 @@ spawn_helper_child (struct app_context *ctx)
} }
static void static void
launch_backlog_helper (struct app_context *ctx, FILE *backlog) launch_backlog_helper (struct app_context *ctx, int backlog_fd)
{ {
hard_assert (!ctx->running_backlog_helper); hard_assert (!ctx->running_backlog_helper);
switch (spawn_helper_child (ctx)) switch (spawn_helper_child (ctx))
{ {
case 0: case 0:
dup2 (fileno (backlog), STDIN_FILENO); dup2 (backlog_fd, STDIN_FILENO);
execl ("/bin/sh", "/bin/sh", "-c", get_config_string execl ("/bin/sh", "/bin/sh", "-c", get_config_string
(ctx->config.root, "behaviour.backlog_helper"), NULL); (ctx->config.root, "behaviour.backlog_helper"), NULL);
print_error ("%s: %s", print_error ("%s: %s",
@ -10522,7 +10522,7 @@ display_backlog (struct app_context *ctx)
rewind (backlog); rewind (backlog);
set_cloexec (fileno (backlog)); set_cloexec (fileno (backlog));
launch_backlog_helper (ctx, backlog); launch_backlog_helper (ctx, fileno (backlog));
fclose (backlog); fclose (backlog);
} }
@ -10544,7 +10544,7 @@ display_full_log (struct app_context *ctx)
fflush (ctx->current_buffer->log_file); fflush (ctx->current_buffer->log_file);
set_cloexec (fileno (full_log)); set_cloexec (fileno (full_log));
launch_backlog_helper (ctx, full_log); launch_backlog_helper (ctx, fileno (full_log));
fclose (full_log); fclose (full_log);
} }