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
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.
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, 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?
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.