When pidstat was used with option "-l" to display the command name and
all its arguments, a space was added at the end after all the arguments.
Remove it as it is unneeded and it may prevent the user from displaying
lines based on a pattern located at the end of line
(e.g. pidstat -l -C "pattern$" ...)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
len = fread(line, 1, MAX_CMDLINE_LEN - 1, fp);
fclose(fp);
- for (i = 0; i < len; i++) {
- if (line[i] == '\0') {
- line[i] = ' ';
- }
- }
-
if (len) {
+ for (i = 0; i < len - 1; i++) {
+ if (line[i] == '\0') {
+ line[i] = ' ';
+ }
+ }
strncpy(pst->cmdline, line, MAX_CMDLINE_LEN - 1);
pst->cmdline[MAX_CMDLINE_LEN - 1] = '\0';
}