summaryrefslogtreecommitdiff
path: root/runner
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-09-24 10:17:27 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2019-09-24 11:55:47 +0100
commit3c1633abec14679300d52eeaf9fb7b63e435e51e (patch)
treecef008cf3ffcb6b9f398b93bd24e38b901225f7b /runner
parent732d99774ac1aac66e46b914e0bc96d2366167d0 (diff)
runner: Chomp away trailing spaces from cmdline
A minor refinement to remove the trailing spaces after converting the NUL-terminators to spaces. v2: Beware the crafty filename entirely composed of spaces. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'runner')
-rw-r--r--runner/executor.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/runner/executor.c b/runner/executor.c
index 3e012142..1a00237f 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -630,6 +630,10 @@ static const char *get_cmdline(pid_t pid, char *buf, ssize_t len)
if (buf[i] == '\0')
buf[i] = ' ';
+ /* chomp away the trailing spaces */
+ while (len && buf[len - 1] == ' ')
+ --len;
+
buf[len] = '\0'; /* but make sure that we return a valid string! */
return buf;
}