Skip to content

Commit

Permalink
Use exec in py_binary to avoid child processes
Browse files Browse the repository at this point in the history
The current approach for the py_binary wrapper means that deployed
instances of py_binary targets create child processes. This can be a
problem when you try to kill the py_binary target since signals and
such don't necessarily get passed along to the child process.

Using the exec functionality here should avoid this particular
problem. The overall behaviour should remain the same.

--
Change-Id: I20ef081e1da5b28a8aff8514d713b1c387ae7f7e
Reviewed-on: https://bazel-review.git.corp.google.com/#/c/4070/
MOS_MIGRATED_REVID=127929454
  • Loading branch information
Philipp Schrader authored and katre committed Jul 20, 2016
1 parent 279007d commit 3bed4af
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def Main():

try:
sys.stdout.flush()
exit(subprocess.call(args))
os.execv(args[0], args)
except EnvironmentError as e:
# This exception occurs when os.execv() fails for some reason.
if not getattr(e, 'filename', None):
Expand Down

0 comments on commit 3bed4af

Please sign in to comment.