For some reason, siginterrupt() only seems to set the behaviour for the first signal received.
In this example program, the first SIGQUIT appears to do nothing, but the second sigquit prints "SIGQUIT Handler" and s.accept() throws an Interrupted system call exception.
from signal import *
from socket import *
import sys
def sigquitHandler(signum, frame):
print("SIGQUIT Handler")
s = socket()
s.bind(("0.0.0.0", int(sys.argv[1])))
s.listen(5)
signal(SIGQUIT, sigquitHandler)
siginterrupt(SIGQUIT, False)
client, addr = s.accept() # Or any syscall that blocks
client.close()
s.close()
What am i misunderstanding here?
Edit: Here's something else that i can't figure out, in this program, a SIGQUIT interrupts the select(). Is that supposed to happen?
from signal import *
import select
import sys
def sigquitHandler(signum, frame):
print("SIGQUIT Handler")
signal(SIGQUIT, sigquitHandler)
siginterrupt(SIGQUIT, False)
select.select([sys.stdin], [], [])