basic/process-util: allow quoting of commandlines

Since the new functionality is controlled by an option, this causes no change
in output yet, except tests.

The login in the old branch of !(flags & PROCESS_CMDLINE_QUOTE) is essentially
unmodified. But there is an important difference in behaviour: instead of
unconditionally reading the whole virtual file, we now read only 'max_columns'
bytes. This makes out code to write process lists quite a bit more efficient
when there are processes with long command lines.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-05-05 13:59:23 +02:00
parent 82208a9949
commit 61977664e9
4 changed files with 148 additions and 36 deletions
+1
View File
@@ -35,6 +35,7 @@
typedef enum ProcessCmdlineFlags {
PROCESS_CMDLINE_COMM_FALLBACK = 1 << 0,
PROCESS_CMDLINE_USE_LOCALE = 1 << 1,
PROCESS_CMDLINE_QUOTE = 1 << 2,
} ProcessCmdlineFlags;
int get_process_comm(pid_t pid, char **name);