Jul 2, 2020

[Go] signal processing

Each M has a default gsignal goroutine(also each M has g0) to handle signals .
This goroutine is created with a bigger stack (32k, in order to fulfill the requirement by the different OS).

gsignal channels the receiving signals from OS to internal signal.loop queue and there's another channel to dispatch the signal from the signal.loop queue to registered (signal processing) channel.

The signal.loop will dispatch signal to registered channels thus trigger g0 to
schedule those goroutines consuming the channel to run.

Synchronous signals, like SIGBUS or SIGFPE , are not manageable and will be converted to panics.

API:
signal.Notify
signal.Ignore
signal.Stop

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.