Skip to content

Commit

Permalink
Merge pull request #47 from Siecje/master
Browse files Browse the repository at this point in the history
Add prexec_fn to Subprocess call
  • Loading branch information
minrk authored Nov 22, 2017
2 parents 02ba572 + da94609 commit c291a89
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sudospawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def relog_stderr(self, stderr):
# [I date JupyterHub] [W date SingleUser] msg...
sys.stderr.write(line.decode('utf8', 'replace'))

def make_preexec_fn(self):
return None

@gen.coroutine
def do(self, action, **kwargs):
"""Instruct the mediator process to take a given action"""
Expand All @@ -58,7 +61,7 @@ def do(self, action, **kwargs):
cmd.append('--logging=debug')

self.log.debug("Spawning %s", cmd)
p = Subprocess(cmd, stdin=Subprocess.STREAM, stdout=Subprocess.STREAM, stderr=Subprocess.STREAM)
p = Subprocess(cmd, stdin=Subprocess.STREAM, stdout=Subprocess.STREAM, stderr=Subprocess.STREAM, preexec_fn=self.make_preexec_fn())
stderr_future = self.relog_stderr(p.stderr)
# hand the stderr future to the IOLoop so it isn't orphaned,
# even though we aren't going to wait for it unless there's an error
Expand Down Expand Up @@ -109,4 +112,3 @@ def _signal(self, sig):
return True
reply = yield self.do('kill', pid=self.pid, signal=sig)
return reply['alive']

0 comments on commit c291a89

Please sign in to comment.