mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-09 15:28:26 +01:00
stage: don't ignore SIGINT in the child (#2271)
Signal mask is inherited by the child, so when we set it up before Popen, our child ignores SIGINT, which is wrong. What we should've done ideally, is to setup the signal handler after fork() but before exec(). That is pretty much what preexec_fn is used for in Popen, but unfortunately for us, it is not available on windows, so we can't use it. What we will do instead is just setup signal handler after Popen() but before communicate(), which would leave a slight gap where we might also get affected by SIGINTS meant for the child, but that is the best we can do. Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+2
-3
@@ -775,9 +775,6 @@ class Stage(object):
|
||||
main_thread = isinstance(
|
||||
threading.current_thread(), threading._MainThread
|
||||
)
|
||||
if main_thread:
|
||||
old_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||
|
||||
p = None
|
||||
|
||||
try:
|
||||
@@ -789,6 +786,8 @@ class Stage(object):
|
||||
executable=executable,
|
||||
close_fds=True,
|
||||
)
|
||||
if main_thread:
|
||||
old_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||
p.communicate()
|
||||
finally:
|
||||
if main_thread:
|
||||
|
||||
Reference in New Issue
Block a user