Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve signal handling. #532

Merged
merged 1 commit into from
Jan 10, 2023
Merged

Improve signal handling. #532

merged 1 commit into from
Jan 10, 2023

Conversation

guymcswain
Copy link
Collaborator

@guymcswain guymcswain commented May 13, 2022

I. The pigpio library's default signal handler is changed:

  • DMA engines are stopped
  • PID lockfile is removed
  • The system default handler (SIG_DFL) is re-installed
  • The signal is raised again (with Term disposition, see II).

The philosophy here is to do only the essential halting of the DMA engines and avoid any functions that are not signal-safe.

II. The default signal handler is installed only for signals:

  • Having SIG_DFL as the current handler. This prevents signals having been ignored or previously installed with custom handlers from getting overridden.
  • Having Term disposition as defined in signal(7).

III. SIGPIPE, SIGCHLD and SIGWINCH are ignored as before.

IV. SIGUSR1, SIGUSR2 are custom handlers as before.

V. API gpioSetSignalFunc() can set / cancel custom handlers on any signal except:

  • Any signal that was ignored prior to gpioInitialize() or as listed in III.
  • Any signal that was preset prior to gpioInitialise().

A cancelled signal will have its previous handler, which may be the library's default handler, re-installed.

VI. Upon gpioTerminate(), any signal installed by the library will be restored to its original handler. (issue #341)

@guymcswain guymcswain marked this pull request as ready for review January 10, 2023 02:56
@guymcswain guymcswain merged commit 3e0a508 into develop Jan 10, 2023
@guymcswain guymcswain deleted the signals branch January 10, 2023 03:10
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.

1 participant