Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1114112

Summary: pgrep and pkill commands enable too many/incorrect fill flags
Product: Red Hat Enterprise Linux 6 Reporter: Andy Grimm <agrimm>
Component: procpsAssignee: Jan Rybar <jrybar>
Status: CLOSED WONTFIX QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.6CC: albert, bnater, jgoulding, jhonce, kdudka, rvokal, tlavigne
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-27 08:10:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
proposed patch
none
amended patch none

Description Andy Grimm 2014-06-27 18:29:33 UTC
Description of problem:

When matching on process owner, command name, and possibly in some other situations, pgrep and pkill enable too many / incorrect PROC_FILL* flags.  This can lead to poor performance and unnecessary blocking.

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

procps-3.2.8-25.el6.x86_64

How reproducible:

Always

Steps to Reproduce:

Test 1:
strace -e trace=file pgrep httpd

Test 2:
strace -e trace=file pgrep -u apache

Actual results:

In test 1, observe that /proc/<pid>/status and /proc/<pid>/cmdline are opened for processes.

In test 2, observe that /proc/<pid>/status is opened for all processes owned by apache

Expected results:

In the first case, there is no need to open /proc/<pid>/cmdline, and it may be faster to use /proc/<pid>/stat rather than status (I'm unsure on the second point).

In the second case, neither /proc/<pid>/stat nor /proc/<pid>/status is required.

Additional info:

I've tested changing the flag logic in pgrep.c:do_openproc, and the change seems trivial, but the exact patch depends on whether stat or status is really the preferred way to match process names.

Comment 1 Andy Grimm 2014-06-27 18:39:42 UTC
Created attachment 912911 [details]
proposed patch

This is what I tested.

Comment 4 Andy Grimm 2014-11-13 16:44:55 UTC
Created attachment 957225 [details]
amended patch

there was a typo in the original patch here (PROC_STAT should have been PROC_FILLSTAT).  Updated.

Comment 7 Jaromír Cápík 2015-03-04 14:09:53 UTC
The proposed modification can affect the internal logic and cause regressions in corner case scenarios. The internal filling/matching logic will have to be redesigned completely as some of the fill flags lead to duplicating/overwriting of the fields and it's difficult to track that. We (reporter and I) decided to wait till the mess is resolved upstream in order to avoid breaking things.