]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lsns: Fix parser for /proc/<pid>/stat which is including space in comm
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Wed, 23 Nov 2016 05:13:34 +0000 (14:13 +0900)
committerKarel Zak <kzak@redhat.com>
Fri, 2 Dec 2016 12:20:41 +0000 (13:20 +0100)
commit3fcbd7978980dc1a29c626b701333e27599e506d
tree909e4a4dea71964bcf3f9ab41c4a740b83b12e7d
parent12f17a23dfdf51b2cad3dfa48868b385aa19c4af
lsns: Fix parser for /proc/<pid>/stat which is including space in comm

For example, child process of spamd has

    32031 (spamd child) S 32026 32026 32026 0 -1 4210752 338 0 0 0 ...

fscanf("%d %*s %c %d*[^\n]") in read_process() can't parse above as we
expected, because %s only skips non-whitespace. I.e. it parses like
following,

    32031 (spamd child) S 32026 32026 32026 0 -1 4210752 338 0 0 0 ...
    +---+ +----+ +
      %d    %*s  %c

and returns 2 (pid=32031, state=c).

This fixes it by skipping task->comm part manually.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
sys-utils/lsns.c