mirror of https://github.com/fail2ban/fail2ban
Merge pull request #452 from grooverdan/early-sighup-ignore
ENH: move signal.signal(signal.SIGHUP, signal.SIG_IGN) before fork in serverpull/489/merge
commit
d402701b9f
|
@ -419,6 +419,14 @@ class Server:
|
||||||
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731
|
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# When the first child terminates, all processes in the second child
|
||||||
|
# are sent a SIGHUP, so it's ignored.
|
||||||
|
|
||||||
|
# We need to set this in the parent process, so it gets inherited by the
|
||||||
|
# child process, and this makes sure that it is effect even if the parent
|
||||||
|
# terminates quickly.
|
||||||
|
signal.signal(signal.SIGHUP, signal.SIG_IGN)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Fork a child process so the parent can exit. This will return control
|
# Fork a child process so the parent can exit. This will return control
|
||||||
# to the command line or shell. This is required so that the new process
|
# to the command line or shell. This is required so that the new process
|
||||||
|
@ -441,10 +449,6 @@ class Server:
|
||||||
# leader.
|
# leader.
|
||||||
os.setsid()
|
os.setsid()
|
||||||
|
|
||||||
# When the first child terminates, all processes in the second child
|
|
||||||
# are sent a SIGHUP, so it's ignored.
|
|
||||||
signal.signal(signal.SIGHUP, signal.SIG_IGN)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Fork a second child to prevent zombies. Since the first child is
|
# Fork a second child to prevent zombies. Since the first child is
|
||||||
# a session leader without a controlling terminal, it's possible for
|
# a session leader without a controlling terminal, it's possible for
|
||||||
|
|
Loading…
Reference in New Issue