[Jython-checkins] jython: Change subprocess construction such that handles are inherited if not set.
jim.baker
jython-checkins at python.org
Sat Jun 28 08:24:35 CEST 2014
http://hg.python.org/jython/rev/e9156cf6283f
changeset: 7335:e9156cf6283f
user: Jim Baker <jim.baker at rackspace.com>
date: Sat Jun 28 00:21:57 2014 -0600
summary:
Change subprocess construction such that handles are inherited if not set.
Support subprocess termination vs terminate/kill methods.
Fixes http://bugs.jython.org/issue1898 and http://bugs.jython.org/issue2096
files:
Lib/subprocess.py | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -832,7 +832,8 @@
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
- errread, errwrite)
+ errread, errwrite,
+ stdin, stdout, stderr)
if mswindows:
if p2cwrite is not None:
@@ -1295,7 +1296,8 @@
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
- errread, errwrite):
+ errread, errwrite,
+ stdin, stdout, stderr):
"""Execute program (Java version)"""
if isinstance(args, types.StringTypes):
@@ -1316,6 +1318,14 @@
args[0] = executable
builder = java.lang.ProcessBuilder(args)
+
+ if stdin is None:
+ builder.redirectInput(java.lang.ProcessBuilder.Redirect.INHERIT)
+ if stdout is None:
+ builder.redirectOutput(java.lang.ProcessBuilder.Redirect.INHERIT)
+ if stderr is None:
+ builder.redirectError(java.lang.ProcessBuilder.Redirect.INHERIT)
+
# os.environ may be inherited for compatibility with CPython
self._setup_env(dict(os.environ if env is None else env),
builder.environment())
@@ -1396,7 +1406,7 @@
def terminate(self):
"""Terminates the process
"""
- _subprocess.TerminateProcess(self._handle, 1)
+ self._process.destroy()
kill = terminate
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list