Skip to content

Commit 2216e2f

Browse files
committed
Use setproctitle python module, when available. NFC
This makes the process listing easier to read as it just shows `emcc ..` rather than `python3 -E emcc.py`. On many/most systems this won't do anything because the module is not installed. I'm going to pass on writing a test for this for now.
1 parent fc50a96 commit 2216e2f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tools/shared.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ def get_llvm_target():
621621

622622
def init():
623623
utils.set_version_globals()
624+
utils.set_process_title()
624625
setup_temp_dirs()
625626

626627

tools/utils.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@
2727
logger = logging.getLogger('utils')
2828

2929

30+
def set_process_title():
31+
"""Remove the python prefix of the process title.
32+
33+
This makes the process listing easier to read as it just shows
34+
`emcc ..` rather than e.g. `python3 -E emcc.py ...`.
35+
36+
This code depends the `setproctitle` PiPi module which might
37+
not be installed. If the module cannot be loaded this function
38+
simply does nothing.
39+
"""
40+
try:
41+
import setproctitle
42+
except:
43+
return
44+
t = setproctitle.getproctitle()
45+
t = shlex.split(t)
46+
while t and not t[0].endswith('.py'):
47+
t.pop(0)
48+
if t:
49+
t[0] = os.path.splitext(t[0])[0]
50+
setproctitle.setproctitle(shlex.join(t))
51+
52+
3053
def run_process(cmd, check=True, input=None, *args, **kw):
3154
"""Runs a subprocess returning the exit code.
3255

0 commit comments

Comments
 (0)