On Fri, Feb 19, 2021 at 06:49:45AM +0100, Sebastien Marie wrote:
> On Thu, Feb 18, 2021 at 10:23:05PM -0600, Edgar Pettijohn wrote:
> > I'm having trouble using kevent(2) to catch signals. Below is a sample
> > program. It should catch SIGHUP and SIGUSR1 and just print it out.
> > Instead when i send the process sighup with `kill -SIGHUP $PID` it
> > exits and the word Hangup is writtin to the terminal. If I use
> > `kill -SIGUSR1 $PID` the process exits and the words User defined signal 1
> > are written to the terminal. What am I doing wrong?
> 
> to quote kqueue(2) man page about signals:
> 
>    [EVFILT_SIGNAL] coexists with the signal(3) and sigaction(2)
>    facilities, and has a lower precedence.  The filter will record all
>    attempts to deliver a signal to a process, even if the signal has
>    been marked as SIG_IGN.  Event notification happens after normal
>    signal delivery processing.

I read this and it just didn't click.

> 
> and to quote signal(3) man page about default action:
> 
>      Name         Default Action       Description
>    SIGHUP       terminate process    terminal line hangup
>    SIGUSR1      terminate process    user-defined signal 1
> 
> Your program needs to first ignore SIGHUP and SIGUSR1 (so the process
> will not terminate). This way, the kqueue(2) subsystem should be able
> to process them correctly.
> 
> Thanks.
> -- 
> Sebastien Marie

With the proper signal({SIGHUP,SIGUSR1}, SIG_IGN) calls it works as expected.

Thanks,

        Edgar

Reply via email to