summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-12-31 03:46:06 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-12-31 05:07:28 +0100
commit8f229f41e1fe580ed30cd47ebb7af5ce5f225532 (patch)
tree5c69e1e3f350d373cdb3b7e464af9f25e6d1c154
parentb4d6decc06176be40db5d1b4b68d941775c7789e (diff)
downloadxK-8f229f41e1fe580ed30cd47ebb7af5ce5f225532.tar.gz
xK-8f229f41e1fe580ed30cd47ebb7af5ce5f225532.tar.xz
xK-8f229f41e1fe580ed30cd47ebb7af5ce5f225532.zip
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.
-rw-r--r--degesch.c8
1 files 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);
}