chiark / gitweb /
util-lib: rework get_process_cmdline() (#3529)
authorLennart Poettering <lennart@poettering.net>
Tue, 14 Jun 2016 21:52:29 +0000 (23:52 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:13:01 +0000 (10:13 +0200)
commitdaf3399a4b667bcdb45757608989a60eeec4a4fe
tree3f2d6e860455ea4a3591fb108b3ce84451e62b83
parentd046fa2e88ab824e7dc3e32172328357779ab0f6
util-lib: rework get_process_cmdline() (#3529)

This reworks get_process_cmdline() quite substantially, fixing the following:

- Fixes:
  https://github.com/elogind/elogind/pull/3512/commits/a4e3bf4d7ac2de51191ce136ee9361ba319e106c#r66837630

- The passed max_length is also applied to the "comm" name, if comm_fallback is
  set.

- The right thing happens if max_length == 1 is specified

- when the cmdline "foobar" is abbreviated to 6 characters the result is not
  "foobar" instead of "foo...".

- trailing whitespace are removed before the ... suffix is appended. The 7
  character abbreviation of "foo barz" is hence "foo..." instead of "foo ...".

- leading whitespace are suppressed from the cmdline

- a comprehensive test case is added
src/basic/process-util.c