Page MenuHomeFreeBSD

Teach ps(1) to select processes by parent process ID.
AcceptedPublic

Authored by tmunro on Jul 30 2019, 11:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 11 2024, 3:03 PM
Unknown Object (File)
Dec 23 2023, 10:07 AM
Unknown Object (File)
Dec 1 2023, 5:35 AM
Unknown Object (File)
Nov 9 2023, 11:32 PM
Unknown Object (File)
Nov 7 2023, 11:43 PM
Unknown Object (File)
Nov 6 2023, 9:36 AM
Unknown Object (File)
Nov 5 2023, 3:30 PM
Unknown Object (File)
Nov 5 2023, 3:25 AM

Details

Reviewers
dteske
allanjude
pstef
Group Reviewers
manpages
Summary

On Linux you can use ps --ppid for this. There is nothing in POSIX. I chose -P because it's not used in POSIX or Linux or well known BSDs, though unfortunately it means something different on Solaris so maybe it's a bad choice.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dteske requested changes to this revision.EditedJul 31 2019, 1:37 PM
dteske added a subscriber: dteske.

After thought, I support this change.

FreeBSD has never had this flag before, so we wouldn't be breaking anything. If someone were to try and run a Solaris script on BSD, they would have got an error about -P not being supported. Were it the case that we were repurposing -P, then there might be concern for issues, but adding a new flag that has never been there before ought to be safe.

This revision now requires changes to proceed.Jul 31 2019, 1:37 PM
This revision is now accepted and ready to land.Jul 31 2019, 6:27 PM

Perhaps it's better to convert ps to use getopt_long() so that we do not invent new single-letter options.

Also, filtering by ppid can be done with existing means, for example ps axl | awk -v ppid=1 'NR == 1 || $3 == ppid'

OK from manpages. Don't forget to bump the .Dd to the date of the commit. Thanks!

allanjude added a subscriber: allanjude.

Approved By: allanjude

Ok, based on feedback here and elsewhere, here's a version that uses getopt_long() from libc. It supports both --ppid (like Linux ps) and -P (like pgrep), and it seemed reasonable to add obvious long opts for --pid, --tty and --jail too. I decided not to try to add Linux-like --user, --User, --group, --Group in this patch (-u, -U, -g, -G all look a bit unportable and complicated). Thoughts?

This revision now requires review to proceed.Aug 2 2019, 11:35 AM
pstef added a subscriber: pstef.

I tested this and it works for me. The patch as a whole will look good to me when synopsis is updated to reflect the change.

This revision is now accepted and ready to land.Aug 15 2021, 7:00 PM