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. 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