Skip to content

Commit

Permalink
Replace null characters with whitespaces in command lines
Browse files Browse the repository at this point in the history
In linux / unix environments, command lines are parsed by the shell and used to launch the process with its argument list broken down into null terminated strings.

When reading the command line from procfs, the null character is also used to separate each argv[i].

Since this is inconvenient for searching processes, I decided to replace the null character with a whitespace character when readling the command line.
  • Loading branch information
sj-i committed Feb 6, 2022
1 parent 10c591a commit c76515c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Lib/Process/ProcFileSystem/CommandLineEnumerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getIterator()
if (!is_numeric(basename($item->getPath()))) {
continue;
}
yield (int)basename($item->getPath()) => $command_line;
yield (int)basename($item->getPath()) => preg_replace('/\0/', ' ', $command_line);
}
}
}

0 comments on commit c76515c

Please sign in to comment.