Bug 193116 - pgrep -f init doesn't show pid = 1, but pgrep -af init does
Summary: pgrep -f init doesn't show pid = 1, but pgrep -af init does
Status: Closed Feedback Timeout
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Fernando Apesteguía
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-29 08:02 UTC by Enji Cooper
Modified: 2023-02-02 09:06 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer freebsd_triage 2014-08-29 08:02:38 UTC
pgrep -f init doesn't return anything on FreeBSD, but it does on Linux:

$ uname -a
FreeBSD freebsd-10-x64.localdomain 10.0-STABLE FreeBSD 10.0-STABLE #2 r270252+223d76d(stable/10): Wed Aug 20 20:55:18 PDT 2014     root@freebsd-10-x64.localdomain:/usr/obj/usr/src/sys/GENERIC-WITHOUT-WITNESS  amd64
$ pgrep -f init
$ pgrep -af init
75489
1
$

This is present on a custom version of 7.x, 10, and 11.
Comment 1 Jilles Tjoelker freebsd_committer freebsd_triage 2014-08-31 13:17:01 UTC
This was deliberately changed in SVN r192242, which excludes the pkill process itself and its ancestors, unless -a is given. Do you think a special case should be added here, or r192242 should be reverted? Note that the main sshd process may somewhat similarly be an ancestor (or not, even if the user is logged in via ssh).

Why are you using pgrep on init anyway, given that its PID is always 1?
Comment 2 Enji Cooper freebsd_committer freebsd_triage 2014-09-01 03:54:00 UTC
(In reply to Jilles Tjoelker from comment #1)
> This was deliberately changed in SVN r192242, which excludes the pkill
> process itself and its ancestors, unless -a is given. Do you think a special
> case should be added here, or r192242 should be reverted? Note that the main
> sshd process may somewhat similarly be an ancestor (or not, even if the user
> is logged in via ssh).

I agree with bryan about the change for pkill, but it would be nice if pgrep defaulted to the old behavior :/.

> Why are you using pgrep on init anyway, given that its PID is always 1?

Just for testing purposes because I was trying to prove that I was sane based on the way I was using the tool :).
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2014-09-01 03:54:32 UTC
(In reply to Garrett Cooper from comment #2)
> (In reply to Jilles Tjoelker from comment #1)
> > This was deliberately changed in SVN r192242, which excludes the pkill
> > process itself and its ancestors, unless -a is given. Do you think a special
> > case should be added here, or r192242 should be reverted? Note that the main
> > sshd process may somewhat similarly be an ancestor (or not, even if the user
> > is logged in via ssh).
> 
> I agree with bryan about the change for pkill, but it would be nice if pgrep
> defaulted to the old behavior :/.

*brian
Comment 4 Fernando Apesteguía freebsd_committer freebsd_triage 2023-01-24 16:19:58 UTC
Is this still considered a bug? The behavior is still the same in 14-CURRENT.