RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1803640 - pidof is broken for kernel threads
Summary: pidof is broken for kernel threads
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: procps-ng
Version: 8.1
Hardware: All
OS: Linux
low
high
Target Milestone: rc
: 8.0
Assignee: Jan Rybar
QA Contact: Karel Volný
URL:
Whiteboard:
Depends On:
Blocks: 1969400
TreeView+ depends on / blocked
 
Reported: 2020-02-17 05:31 UTC by Malahal
Modified: 2021-06-08 13:31 UTC (History)
3 users (show)

Fixed In Version: procps-ng-3.3.15-2.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 01:38:34 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:4459 0 None None None 2020-11-04 01:38:37 UTC

Description Malahal 2020-02-17 05:31:42 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Malahal 2020-02-17 05:34:10 UTC
For example: "pidof kswapd0" returns empty list on RHEL8.x but return a PID on RHEL7.x

Comment 2 Malahal 2020-02-17 05:36:22 UTC
In pidof.c file, if task.cmdline is not available (not available for kernel threads), using task.cmd is an option to fix this.

Comment 3 Jan Rybar 2020-04-07 13:56:03 UTC
Hello Malahal,

first, I will explain the pidof's behaviour you're experiencing.
Pidof in RHEL7 was part of sysvinit-tools component. Since sysvinit-tools was abandoned in RHEL8, pidof was completely rewritten for the inclusion within procps-ng component. This reimplementation brought some behavioral changes, as you may notice.

I took the liberty of lowering the urgency of this bug, as there is a workaround for this issue.
procps-ng component contains a tool 'pgrep' which can provide the same results as pidof and also has some good perks (I suggest to check the manpage), as it can match even substrings of the target program, UIDs, PPIDs, PGIDs etc.

To get results similar to pidof's, try
$ pgrep -f $your_program

TBH I rarely use pidof in favor of pgrep.

Since a convenient workaround exists, I enabled Devel CONDNAK to see if upstream accepts the patch of pidof I sent there.
If it is vital for your usage to have pidof fixed (I would really love to know the use-case, just for statistical knowledge), we can discuss it further.

Enjoy and have a nice day!

Comment 4 Jan Rybar 2020-04-14 10:31:23 UTC
Fix accepted by upstream.

Comment 8 Bryan Hill 2020-06-01 15:39:56 UTC
(In reply to Jan Rybar from comment #3)
> Hello Malahal,
> 
> first, I will explain the pidof's behaviour you're experiencing.
> Pidof in RHEL7 was part of sysvinit-tools component. Since sysvinit-tools
> was abandoned in RHEL8, pidof was completely rewritten for the inclusion
> within procps-ng component. This reimplementation brought some behavioral
> changes, as you may notice.
> 
> I took the liberty of lowering the urgency of this bug, as there is a
> workaround for this issue.
> procps-ng component contains a tool 'pgrep' which can provide the same
> results as pidof and also has some good perks (I suggest to check the
> manpage), as it can match even substrings of the target program, UIDs,
> PPIDs, PGIDs etc.
> 
> To get results similar to pidof's, try
> $ pgrep -f $your_program
> 
> TBH I rarely use pidof in favor of pgrep.
> 
> Since a convenient workaround exists, I enabled Devel CONDNAK to see if
> upstream accepts the patch of pidof I sent there.
> If it is vital for your usage to have pidof fixed (I would really love to
> know the use-case, just for statistical knowledge), we can discuss it
> further.
> 
> Enjoy and have a nice day!


Hello!

I can provide an answer to this, as I was working with Malahal on the issue.  The pidof command, in this particular case, is used by the NFS monitoring script used in the clustered NFS functionality in IBM Spectrum Scale (GPFS).  It looks for pids of nfsd kernel threads and if there are none detected, it shuts the node down.  Since pidof changed, no nfsd pids are returned, and therefore causes causes the node shutdown.  But I see the fix is in QA so that's good news. 

Thanks,
Bryan

Comment 12 errata-xmlrpc 2020-11-04 01:38:34 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (procps-ng bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4459

Comment 13 Arpit Tolani 2021-05-03 06:43:43 UTC
It is still not working after upgrading to latest package. 

# rpm -q procps-ng
procps-ng-3.3.15-3.el8_3.1.x86_64

# ps aux |grep nfsd
root        7229  0.0  0.1  50132  2392 ?        Ss   09:25   0:00 /usr/sbin/nfsdcld
root       12934  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
root       12938  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
root       12942  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
root       12946  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
root       12947  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
root       12948  0.1  0.0      0     0 ?        S    09:27   0:01 [nfsd]
root       12949  0.4  0.0      0     0 ?        S    09:27   0:03 [nfsd]
root       12950  2.5  0.0      0     0 ?        S    09:27   0:22 [nfsd]
root       44818  0.0  0.0  12112  1020 pts/0    R+   09:41   0:00 grep --color=auto nfsd

# pidof nfsd

# pgrep -f nfsd
7229
12934
12938
12942
12946
12947
12948
12949
12950

Comment 14 Jan Rybar 2021-05-03 07:02:52 UTC
(In reply to Arpit Tolani from comment #13)
> It is still not working after upgrading to latest package. 
> 
> # rpm -q procps-ng
> procps-ng-3.3.15-3.el8_3.1.x86_64
> 
> # ps aux |grep nfsd
> root        7229  0.0  0.1  50132  2392 ?        Ss   09:25   0:00
> /usr/sbin/nfsdcld
> root       12934  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> root       12938  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> root       12942  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> root       12946  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> root       12947  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> root       12948  0.1  0.0      0     0 ?        S    09:27   0:01 [nfsd]
> root       12949  0.4  0.0      0     0 ?        S    09:27   0:03 [nfsd]
> root       12950  2.5  0.0      0     0 ?        S    09:27   0:22 [nfsd]
> root       44818  0.0  0.0  12112  1020 pts/0    R+   09:41   0:00 grep
> --color=auto nfsd
> 
> # pidof nfsd
> 
> # pgrep -f nfsd
> 7229
> 12934
> 12938
> 12942
> 12946
> 12947
> 12948
> 12949
> 12950

Hello,

pidof needs to be run with '-x' parameter to show kernel workers.
Implementing this functionality into default behavior would break numerous scripts.

Comment 15 Jan Rybar 2021-05-03 07:03:40 UTC
(In reply to Jan Rybar from comment #14)
> (In reply to Arpit Tolani from comment #13)
> > It is still not working after upgrading to latest package. 
> > 
> > # rpm -q procps-ng
> > procps-ng-3.3.15-3.el8_3.1.x86_64
> > 
> > # ps aux |grep nfsd
> > root        7229  0.0  0.1  50132  2392 ?        Ss   09:25   0:00
> > /usr/sbin/nfsdcld
> > root       12934  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> > root       12938  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> > root       12942  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> > root       12946  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> > root       12947  0.0  0.0      0     0 ?        S    09:27   0:00 [nfsd]
> > root       12948  0.1  0.0      0     0 ?        S    09:27   0:01 [nfsd]
> > root       12949  0.4  0.0      0     0 ?        S    09:27   0:03 [nfsd]
> > root       12950  2.5  0.0      0     0 ?        S    09:27   0:22 [nfsd]
> > root       44818  0.0  0.0  12112  1020 pts/0    R+   09:41   0:00 grep
> > --color=auto nfsd
> > 
> > # pidof nfsd
> > 
> > # pgrep -f nfsd
> > 7229
> > 12934
> > 12938
> > 12942
> > 12946
> > 12947
> > 12948
> > 12949
> > 12950
> 
> Hello,
> 
> pidof needs to be run with '-x' parameter to show kernel workers.
> Implementing this functionality into default behavior would break numerous
> scripts.

Sorry, '-w' parameter.


Note You need to log in before you can comment on or make changes to this bug.