sindresorhus / fkill-cli

Fabulously kill processes. Cross-platform.
MIT License
6.88k stars 159 forks source link

Add verbose option to search arguments as well as command names #14

Closed dnbkr closed 7 years ago

dnbkr commented 7 years ago

This feature allows you to run fkill -v and then when searching for processes to kill, it will include the full proc command (including arguments)

This is useful when I have a daemonic process, like a dev web server, that I want to kill, but was launched with python start_web_server.py for example.


Fixes #13 Fixes #18

knownasilya commented 7 years ago

Excellent!

dnbkr commented 7 years ago

Hi,

Just wondering if you've had a chance to look at this yet?

Daniel

sindresorhus commented 7 years ago

Generally looks good :)

You should limit the length though. Chrome has some crazy long process arguments:

/Applications/Google Chrome.app/Contents/Versions/56.0.2924.87/Google Chrome Helper.app/Contents/MacOS/Google Chrome Helper --type=renderer --enable-feature
s=AutofillProfileCleanup<AutofillProfileCleanup,BlockSmallPluginContent<PluginPowerSaverTiny,EnableSyncClientToServerCompression<EnableSyncClientToServerCompr
ession,*ExpectCTReporting<ExpectCTReporting,*NegotiateTLS13<TLS13Negotiation,ParseHTMLOnMainThread<ParseHTMLOnMainThread,PersistentHistograms<PersistentHistog
rams,*PointerEvent<PointerEvent,PreferHtmlOverPlugins<Html5ByDefault,SecurityChip<SecurityChip,SecurityWarningIconUpdate<SecurityWarningIconUpdate,Subresource
Filter<SubresourceFilter,*TranslateRankerLogging<TranslateRankerLogging,ViewsSimplifiedFullscreenUI<ViewsSimplifiedFullscreenUI --disable-features=DocumentWri
teEvaluator<DisallowFetchForDocWrittenScriptsInMainFrame,SSLPostQuantumExperiment<SSLPostQuantum --force-fieldtrials=*AppBannerTriggering/LanguageAdd/*Autofil
lProfileCleanup/Enabled/CaptivePortalInterstitial/Enabled/*ChromeChannelStable/Enabled/*ChromeSuggestionsTuning/Default/*ClientSideDetectionModel/Model0/*Data
ReductionProxyUseQuic/Enabled10_NoControl/*DisallowFetchForDocWrittenScriptsInMainFrame/DocumentWriteScriptBlockGroup_20161208_Launch/*EnableSyncClientToServe
rCompression/Enabled/ExpectCTReporting/ExpectCTReportingDisabled/*ExtensionDeveloperModeWarning/Enabled/*ExtensionInstallVerification/Enforce/*Html5ByDefault/
Enabled/*InstanceID/Enabled/*MarkNonSecureAs/show-non-secure-passwords-cc-ui/*OmniboxBundledExperimentV1/StandardR7/*ParseHTMLOnMainThread/Default/PasswordBra
nding/SmartLockBrandingSavePromptOnly/*PasswordGeneration/Disabled/*PasswordManagerSettingsMigration/Enable/*PersistentHistograms/EnabledInMemory/*PluginPower
SaverTiny/Enabled2/*QUIC/EnabledNoId/ReportCertificateErrors/ShowAndPossiblySend/SHA1IdentityUIWarning/Enabled/SHA1ToolbarUIJanuary2016/Warning/SHA1ToolbarUIJ
anuary2017/Error/SSLCommonNameMismatchHandling/Enabled/*SSLPostQuantum/disabled/*SafeBrowsingIncidentReportingService/Default/SafeBrowsingUnverifiedDownloads/
DisableByParameterMostSbTypes2/SafeBrowsingV4LocalDatabaseManagerEnabled/Default/*SecurityChip/Enabled/SecurityWarningIconUpdate/Enabled/SignInPasswordPromo/E
nable3/*SiteIsolationExtensions/Enabled_100/*StrictSecureCookies/Enabled/*SubresourceFilter/EnabledForPhishingSites/*TLS13Negotiation/Default/*TranslateRanker
Logging/TranslateRankerLoggingDefault/*TranslateServerStudy/Default/*UMA-Dynamic-Uniformity-Trial/Group3/*UMA-Population-Restrict/normal/*UMA-Uniformity-Trial
-1-Percent/group_13/*UMA-Uniformity-Trial-10-Percent/group_04/*UMA-Uniformity-Trial-100-Percent/group_01/*UMA-Uniformity-Trial-20-Percent/group_03/*UMA-Unifor
mity-Trial-5-Percent/group_13/*UMA-Uniformity-Trial-50-Percent/group_01/*WebFontsInterventionV2/Default/ --primordial-pipe-token=93C0072AEDA354DB6C67392A6B27A
92F --lang=en-US --metrics-client-id=9f725972-7a9e-4133-b210-03300eef79c1 --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --blink-setti
ngs=disallowFetchForDocWrittenScriptsInMainFrame=false,disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections=true --enable-pinch --num-raster-threads=
4 --enable-gpu-rasterization --enable-zero-copy --enable-gpu-memory-buffer-compositor-resources --enable-main-frame-before-activation --content-image-texture-
target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,3553;0,10,34037;0,11,34037;0,12,34037;0,13,3553;0,14,3553;0,15,355
3;1,0,3553;1,1,3553;1,2,3553;1,3,3553;1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,34037;1,11,34037;1,12,34037;1,13,3553;1,14,3553;1,15,3553;2,0
,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,34037;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10,3553;2,11,3553;2,12,34037;2,13,3553;2,14,34037;2,15,34037;3,0,355
3;3,1,3553;3,2,3553;3,3,3553;3,4,3553;3,5,34037;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,34037;3,13,3553;3,14,34037;3,15,34037 --service-r
equest-channel-token=93C0072AEDA354DB6C67392A6B27A92F --renderer-client-id=75
sindresorhus commented 7 years ago

I know it's verbose mode, but I think we should simplify the apps in this mode:

/Applications/iTerm.app/Contents/MacOS/iTerm2 => /Applications/iTerm.app

knownasilya commented 7 years ago

@sindresorhus this comment https://github.com/sindresorhus/fkill-cli/issues/13#issuecomment-283704892 regarding the chrome processes might be helpful.

dnbkr commented 7 years ago

Have updated based on feedback; yet to sort out extracting the process name from the args and truncating the macOS .app insides. Will take a look at that later today hopefully.

Updates address help output, truncating overly verbose procs to one line, passing flags throughout the app

dnbkr commented 7 years ago

Changes to ps-list to extract args from command will solve issues such as:

/Applications/iTerm.app/Contents/MacOS/iTerm2 => /Applications/iTerm.app

(I was thinking of removing all text after /Contents/MacOS until we hit a space, but this would fail for applications with a space in their name, so waiting for the changes to ps-list would be better overall, i think)

Excluding the integration with future ps-list changes, have I missed anything?

sindresorhus commented 7 years ago

You need to resolve the merge conflict.

sindresorhus commented 7 years ago

Yay! Thanks for working on this @coffeedoughnuts. Good stuff.

happy

sindresorhus commented 7 years ago

@coffeedoughnuts Would you be interested in being a maintainer on this project? You did such a great job with this PR. No worries if not though :)

dnbkr commented 7 years ago

@sindresorhus hey - i've not maintained an open source project before; what exactly would it involve? (Just responding to issues and approving PRs?)

Would be interested though; mainly contributed to this one because i'm so sick of ps aux | grep <something> and then copy-pasting the proc id to kill - saw your tool and thought it's exactly what i needed for work!

SamVerschueren commented 7 years ago

Being kind to people is always the first thing to do :). And then yes, helping to triage issues and review PRs. I always let @sindresorhus make the final decision though as it's his project so he's the one to decide on new features etc. Something I forgot to mention?

dnbkr commented 7 years ago

well - happy to help in any way i can :)

sindresorhus commented 7 years ago

@coffeedoughnuts Yes, what Sam said. Just helping out in any way you feel like :)

pirate commented 7 years ago

Hey guys, just testing this on my local machine and ran into some problems. It seems fkill is having trouble killing some processes when I search for them by argument (the procs are owned by me, and are killable with kill):

➜  ps ax | grep -v grep | grep runserver
90766 s003  S+     0:01.05 python ./manage.py runserver
90769 s003  S+    11:45.73 /Users/squash/.virtualenvs/grater/bin/python ./manage.py runserver
➜  fkill -v
? Running processes: runserv
? Running processes: python ./manage.py runserver 90766

AggregateError:
    Error: Killing process python ./manage.py runserver 90766 failed: No matching processes belonging to you were found
        at Promise.all.then (/Users/squash/.config/yarn/global/node_modules/fkill/index.js:41:10)
    at Promise.all.then (/Users/squash/.config/yarn/global/node_modules/fkill/index.js:41:10)
[1]
dnbkr commented 7 years ago

@pirate thanks for pointing that out; not sure how i let that one slip through. I've made a bug fix PR to fix this issue ( #25 )