Skip to content

Handle SIGTERM and SIGINT for clean exit#317

Merged
v1cont merged 1 commit intov1cont:masterfrom
Mgdev-25:fix/signal-handling
Dec 3, 2025
Merged

Handle SIGTERM and SIGINT for clean exit#317
v1cont merged 1 commit intov1cont:masterfrom
Mgdev-25:fix/signal-handling

Conversation

@mg-dev25
Copy link
Contributor

@mg-dev25 mg-dev25 commented Dec 2, 2025

Handle SIGTERM and SIGINT for clean exit

Adds signal handlers for SIGTERM and SIGINT using the existing sa_usr2() handler. Follows the feedback on PR #314 about reusing existing handlers.

What changed

Two lines added to the signal handler setup:

signal (SIGTERM, sa_usr2);  /* Clean exit on SIGTERM */
signal (SIGINT, sa_usr2);   /* Clean exit on SIGINT (Ctrl+C) */

The existing sa_usr2() handler exits with YAD_RESPONSE_CANCEL, which is the appropriate response for interrupted dialogs.

Why

Scripts embedding YAD dialogs need to properly terminate them when interrupted or receiving signals from process managers. Without this, SIGTERM and SIGINT would use the default behavior (immediate termination) instead of the clean exit path.

Testing

# Start dialog and send SIGTERM
yad --text="Test" &
kill $!
echo "Exit code: $?"  # Should be 1 (CANCEL)

# Start dialog and press Ctrl+C
yad --text="Test"  # Press Ctrl+C, should exit cleanly

Adds handlers for SIGTERM and SIGINT signals using the existing sa_usr2()
handler, which cleanly exits with YAD_RESPONSE_CANCEL.

This allows scripts to properly terminate YAD dialogs when interrupted
(Ctrl+C) or when receiving SIGTERM from process managers.

Follows feedback from PR v1cont#314 about reusing existing handlers instead of
creating new ones.
@v1cont v1cont merged commit 5d264b1 into v1cont:master Dec 3, 2025
@mg-dev25 mg-dev25 deleted the fix/signal-handling branch December 4, 2025 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments