Skip to content

Commit

Permalink
Fix inherits environment variables (elastic#8849)
Browse files Browse the repository at this point in the history
We were inheriting environment variables on windows only, this make sure
the variables are inherited on unix too. Because the system module in
metricbeat uses `lsof` since the environment variables were cleared the
$PATH was not available so the binary was not found.

fixes: elastic#8848
  • Loading branch information
ph authored Oct 31, 2018
1 parent 93cedb8 commit 67abf3b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions libbeat/tests/system/beat/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ def __init__(self, args, outputfile, env={}):
self.env = env

def start(self):
# ensure that the environment is inherited to the subprocess.
variables = os.environ.copy()
variables = variables.update(self.env)

if sys.platform.startswith("win"):
# ensure that the environment is inherited to the subprocess.
variables = os.environ.copy()
variables = variables.update(self.env)

self.proc = subprocess.Popen(
self.args,
stdin=self.stdin_read,
Expand All @@ -66,7 +65,7 @@ def start(self):
stdout=self.output,
stderr=subprocess.STDOUT,
bufsize=0,
env=self.env)
env=variables)
# If a "No such file or directory" error points you here, run
# "make metricbeat.test" on metricbeat folder
return self.proc
Expand Down

0 comments on commit 67abf3b

Please sign in to comment.