Skip to content

Commit 734538a

Browse files
committed
make pgrep_maps compatible with pdeathsigger
1 parent 31cc0eb commit 734538a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

gprofiler/utils/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def start_process(cmd: Union[str, List[str]], via_staticx: bool = False, **kwarg
104104
if isinstance(cmd, str):
105105
cmd = [cmd]
106106

107+
if is_linux():
108+
cmd = [resource_path("pdeathsigger")] + cmd if is_linux() else cmd
109+
107110
logger.debug("Running command", command=cmd)
108111

109112
env = kwargs.pop("env", None)
@@ -123,7 +126,7 @@ def start_process(cmd: Union[str, List[str]], via_staticx: bool = False, **kwarg
123126
env.update({"LD_LIBRARY_PATH": ""})
124127

125128
process = Popen(
126-
[resource_path("pdeathsigger")] + cmd if is_linux() else cmd,
129+
cmd,
127130
stdout=kwargs.pop("stdout", subprocess.PIPE),
128131
stderr=kwargs.pop("stderr", subprocess.PIPE),
129132
stdin=subprocess.PIPE,
@@ -310,10 +313,9 @@ def pgrep_maps(match: str) -> List[Process]:
310313
# this is much faster than iterating over processes' maps with psutil.
311314
# We use flag -E in grep to support systems where grep is not PCRE
312315
result = run_process(
313-
f"grep -lE '{match}' /proc/*/maps",
316+
["sh", "-c", f"grep -lE '{match}' /proc/*/maps"],
314317
stdout=subprocess.PIPE,
315318
stderr=subprocess.PIPE,
316-
shell=True,
317319
suppress_log=True,
318320
check=False,
319321
)

0 commit comments

Comments
 (0)