diff --git a/honcho/command.py b/honcho/command.py index ce4ba55..0b533ee 100644 --- a/honcho/command.py +++ b/honcho/command.py @@ -3,6 +3,7 @@ import logging import os import sys +import signal from collections import defaultdict from pkg_resources import iter_entry_points @@ -157,7 +158,9 @@ def command_run(args): else: cmd = ' '.join(compat.shellquote(arg) for arg in args.argv) - p = Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) + p = Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, + start_new_session=False) + signal.signal(signal.SIGINT, signal.SIG_IGN) p.wait() sys.exit(p.returncode) diff --git a/honcho/process.py b/honcho/process.py index 4d31d82..669c8ef 100644 --- a/honcho/process.py +++ b/honcho/process.py @@ -66,6 +66,7 @@ def _send_message(self, data, type='line'): class Popen(subprocess.Popen): def __init__(self, cmd, **kwargs): + start_new_session = kwargs.pop('start_new_session', True) options = { 'stdout': subprocess.PIPE, 'stderr': subprocess.STDOUT, @@ -81,9 +82,10 @@ def __init__(self, cmd, **kwargs): create_new_process_group = 0x00000200 detached_process = 0x00000008 options.update(creationflags=detached_process | create_new_process_group) - elif sys.version_info < (3, 2): - options.update(preexec_fn=os.setsid) - else: - options.update(start_new_session=True) + elif start_new_session: + if sys.version_info < (3, 2): + options.update(preexec_fn=os.setsid) + else: + options.update(start_new_session=True) super(Popen, self).__init__(cmd, **options)