Skip to content

Commit b35fc62

Browse files
author
Xavier de Gaye
committed
Issue python#16255: subrocess.Popen uses /system/bin/sh on Android as the shell,
instead of /bin/sh.
1 parent f191a9e commit b35fc62

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lib/subprocess.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,10 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
12041204
args = list(args)
12051205

12061206
if shell:
1207-
args = ["/bin/sh", "-c"] + args
1207+
# On Android the default shell is at '/system/bin/sh'.
1208+
unix_shell = ('/system/bin/sh' if
1209+
hasattr(sys, 'getandroidapilevel') else '/bin/sh')
1210+
args = [unix_shell, "-c"] + args
12081211
if executable:
12091212
args[0] = executable
12101213

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ Core and Builtins
177177
Library
178178
-------
179179

180+
- Issue #16255: subrocess.Popen uses /system/bin/sh on Android as the shell,
181+
instead of /bin/sh.
182+
180183
- Issue #28779: multiprocessing.set_forkserver_preload() would crash the
181184
forkserver process if a preloaded module instantiated some
182185
multiprocessing objects such as locks.

0 commit comments

Comments
 (0)