Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headerless ps options result in spurious output #7

Open
treyharris opened this issue Aug 17, 2016 · 0 comments
Open

headerless ps options result in spurious output #7

treyharris opened this issue Aug 17, 2016 · 0 comments

Comments

@treyharris
Copy link

I forked and was about to write a fix to send you a pull request, but then in reading the code I noticed the -n option, which up till now I'd missed. Still, this seems to qualify as a bug, so I thought I'd mention it.

On MacOS If you give options such that the ps header is suppressed completely, you get the PID 1 line from psgrep as the first line of output:

% psgrep -o 'pid=,ppid=,comm=' mosh
    1     0 /sbin/launchd
60243     1 mosh-server
83177  1277 /usr/local/Cellar/mobile-shell/1.2.6/bin/mosh-client my-mbp |
55353  5322 /usr/local/Cellar/mobile-shell/1.2.6/bin/mosh-client trey-mbp-my.local |

clearly it's just interpreting the top line as the header, because giving -n suppresses that:

% psgrep -n -o 'pid=,ppid=,comm=' mosh
60243     1 mosh-server
83177  1277 /usr/local/Cellar/mobile-shell/1.2.6/bin/mosh-client my-mbp |
55353  5322 /usr/local/Cellar/mobile-shell/1.2.6/bin/mosh-client trey-mbp-my.local |

Since the only reason I can see to care about this is when you're trying to suppress the output, and there's an easier way in -n, this is pretty low-priority, but again I thought I'd let you know.

(I don't think this bug can arise on Linux because the only way to create a headerless ps output using options requires passing -o multiple times, which psgrep doesn't support. I haven't tried any other operating systems.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant