From f6deb4f62b6bdc541e9387b37df9156f069d7db1 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 1 Mar 2018 15:29:34 +0000 Subject: [PATCH] scripts: scripts-library.sh: Fix dstat background process command The correct way to background the dstat process is by using (dstat...&) which creates a grandchild process which is inherited by the init process once the child dies. The existing code didn't do that since it was creating a background process of a child process so in the end the child process couldn't be killed by Ansible and the job was timing out. The dstat process is normally being killed as part of the post-run playbook. Moreover, the '3' file descriptor probably doesn't make much sense so we simply redirect stdout and stderr to the logfile and make sure we close the stdin one before going to the background. Change-Id: I62d18c196b9bcd267f28f091af7761e7a514e652 --- scripts/scripts-library.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/scripts-library.sh b/scripts/scripts-library.sh index e539cf7b66..306eeaa9a6 100755 --- a/scripts/scripts-library.sh +++ b/scripts/scripts-library.sh @@ -206,7 +206,8 @@ function run_dstat { # https://stackoverflow.com/a/20338327 executing in ()& decouples the dstat # process from scripts-library to prevent hung builds if dstat fails to exit # for any reason. - (dstat -tcmsdn --top-cpu --top-mem --top-bio --nocolor --output /openstack/log/instance-info/dstat.csv 3 > /openstack/log/instance-info/dstat.log)& + (dstat -tcmsdn --top-cpu --top-mem --top-bio --nocolor --output /openstack/log/instance-info/dstat.csv \ + < /dev/null > /openstack/log/instance-info/dstat.log 2>&1 &) fi }