Skip to content

Conversation

@adamdickmeiss
Copy link
Contributor

When using the daemon utility and flag YAZ_DAEMON_LOG_REOPEN to allow for SIGHUP to re-open log files, it would only work once as the SIGHUP handler action was cleared. Now it remains enabled, so that SIGHUP can be received multiple times.

When using the daemon utility and flag YAZ_DAEMON_LOG_REOPEN to
allow for SIGHUP to re-open log files, it would only work once
as the SIGHUP handler action was cleared. Now it remains
enabled, so that SIGHUP can be received multiple times.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the SIGHUP signal handler for log file reopening would only work once. The issue was caused by using the deprecated signal() function which has platform-dependent behavior that may reset the handler to default after the first invocation.

Changes:

  • Replaced signal() with sigaction() for SIGHUP handler registration to ensure handler persists across multiple signal invocations
  • Added logging statement to track when SIGHUP is received

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sigemptyset(&sa.sa_mask);
sa.sa_handler = log_reopen_handler;
sa.sa_flags = 0;
sigaction(SIGHUP, &sa, 0);
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third argument to sigaction should be NULL instead of 0 for better code clarity. While 0 is technically valid, using NULL makes it explicit that this is a pointer argument and improves code readability.

Suggested change
sigaction(SIGHUP, &sa, 0);
sigaction(SIGHUP, &sa, NULL);

Copilot uses AI. Check for mistakes.
@adamdickmeiss adamdickmeiss merged commit ec3bacd into master Jan 10, 2026
10 checks passed
@adamdickmeiss adamdickmeiss deleted the fix-sighup-cleared branch January 10, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants