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

Use process cmd from ps-list (instead of/with) the name #16

Open
kmarques opened this issue Mar 3, 2017 · 8 comments
Open

Use process cmd from ps-list (instead of/with) the name #16

kmarques opened this issue Mar 3, 2017 · 8 comments

Comments

@kmarques
Copy link

kmarques commented Mar 3, 2017

I think it would be easer to find a process if the full command is used instead of the name.
Indeed, if i have couple of node process running in background, i will have

node 1337
node 1338
node 1339

but if the full command is displayed

node foo.js 1337
node bar.js 1338
node foo-bar.js 1339

an other display could be

node 1337 `node foo.js`
node 1338 `node bar.js`
node 1339 `node foo-bar.js`
@dnbkr
Copy link
Contributor

dnbkr commented Mar 3, 2017

I added support for this with PR #14 - if that gets merged then searching by full command will be possible with fkill -v

@sindresorhus
Copy link
Owner

The reason I didn't use the command with arguments by default is that it's very verbose. It includes the full path to the binary. I could find no way to just extract the arguments as I couldn't split on a space as ps returns paths with spaces unquoted (Happy to be shown otherwise!).

Ideally we would show the binary (without full path) and arguments by default, but as I said, I couldn't find a way to do it cleanly. We could maybe do it for known cases like python and node as we know the binary name, so we could predictable parse it.

@sindresorhus
Copy link
Owner

I looked into this more, and I might have a solution to get the arguments without the full path. It seems ps -o pid -o comm returns the full path without arguments and ps -o pid -o command returns with arguments. So we could get both columns and just diff them to get the arguments. I think this should be added as a new property in ps-list. So we could add an args property with just the arguments and a path property with the full path to the binary without arguments, just for completeness.

@dnbkr
Copy link
Contributor

dnbkr commented Mar 9, 2017

:) I came to the same conclusion last night - wasn't sure how to sort it for Windows users though (and also don't have a window machine, so could not test)

Shall I leave the changes to ps-list to you? Perhaps, if you're busy, we could look at the integration back into fkill-client in another merge and complete this PR #14 without it?

@sindresorhus
Copy link
Owner

wasn't sure how to sort it for Windows users though (and also don't have a window machine, so could not test)

Seems like it should be possible: http://superuser.com/questions/415360/how-do-i-find-out-command-line-arguments-of-a-running-program, but I'm not that concerned about it. We can leave it as PR welcome if any Windows users wants it.

Shall I leave the changes to ps-list to you? Perhaps, if you're busy, we could look at the integration back into fkill-client in another merge and complete this PR #14 without it?

I probably won't have time to do the ps-list changes, so I'll leave them PR welcome, but your PR is not dependent on it.

@sindresorhus
Copy link
Owner

I opened an issue on ps-list: sindresorhus/ps-list#7 (Help welcome)

@pirate
Copy link

pirate commented Mar 14, 2017

I'd like to counter that often the path of the binary is useful for searching, I often kill python processes by searching for the virtualenv the bin is located in. g.g. if I want to kill all processes for a particular project, I'll search for ~/.virtualenvs/projectname/bin.

Maybe we could allow searching the full path, but display an abbreviated version if it's above a certain number of characters?
/bin/sh -c "echo hi"
/U/n/.v/p/bin/python arg1 arg2 arg3 <- path shortened to first letter of each dir except last one

@sindresorhus
Copy link
Owner

@pirate Good point. I would differentiate plain binaries and apps though. For apps you don't care about the path, but you might for binaries. Maybe just doing /Users/sindresorhus/dev/bin/python -> ~/dev/bin/python would be enough. What would have been more useful than the full path is to include the path of where the binary was started, but I don't think that information is available.

You can see the full path with fkill -v now.

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

No branches or pull requests

4 participants