Skip to content

Commit d99bc70

Browse files
committed
More reliable way to determine true command line
1 parent 29f5d73 commit d99bc70

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

instana/fsm.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import os
32
import socket
43
import subprocess
@@ -134,8 +133,15 @@ def announce_sensor(self, e):
134133
cmdinfo = cmd.read()
135134
cmdline = cmdinfo.split('\x00')
136135
else:
137-
cmdline = [sys.executable]
138-
cmdline += sys.argv
136+
# OSX doesn't provide a reliable method to determine what
137+
# the OS process command line may be. Here we are forced to
138+
# rely on ps rather than adding a dependency on something like
139+
# psutil which requires dev packages, gcc etc...
140+
proc = subprocess.Popen(["ps", "-p", str(pid), "-o", "command"],
141+
stdout=subprocess.PIPE)
142+
(out, err) = proc.communicate()
143+
parts = out.split(b'\n')
144+
cmdline = [parts[1].decode("utf-8")]
139145

140146
d = Discovery(pid=pid,
141147
name=cmdline[0],

0 commit comments

Comments
 (0)