Skip to content

Commit

Permalink
Cherry-pick #8849 to 6.5: Fix inherits environment variables (#8856)
Browse files Browse the repository at this point in the history
Cherry-pick of PR #8849 to 6.5 branch. Original message: 

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: #8848
  • Loading branch information
ph authored Oct 31, 2018
1 parent 0f82c1e commit d54b204
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 d54b204

Please sign in to comment.