From 8f229f41e1fe580ed30cd47ebb7af5ce5f225532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Thu, 31 Dec 2015 03:46:06 +0100 Subject: [PATCH] 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. --- degesch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/degesch.c b/degesch.c index 5822bb6..5dce5a9 100644 --- a/degesch.c +++ b/degesch.c @@ -10484,13 +10484,13 @@ spawn_helper_child (struct app_context *ctx) } 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); switch (spawn_helper_child (ctx)) { case 0: - dup2 (fileno (backlog), STDIN_FILENO); + dup2 (backlog_fd, STDIN_FILENO); execl ("/bin/sh", "/bin/sh", "-c", get_config_string (ctx->config.root, "behaviour.backlog_helper"), NULL); print_error ("%s: %s", @@ -10522,7 +10522,7 @@ display_backlog (struct app_context *ctx) rewind (backlog); set_cloexec (fileno (backlog)); - launch_backlog_helper (ctx, backlog); + launch_backlog_helper (ctx, fileno (backlog)); fclose (backlog); } @@ -10544,7 +10544,7 @@ display_full_log (struct app_context *ctx) fflush (ctx->current_buffer->log_file); set_cloexec (fileno (full_log)); - launch_backlog_helper (ctx, full_log); + launch_backlog_helper (ctx, fileno (full_log)); fclose (full_log); }