sindresorhus/taskkill

Warning that termination is not guaranteed

Open

#6 opened on Apr 24, 2017

View on GitHub
 (5 comments) (0 reactions) (0 assignees)JavaScript (10 forks)user submission
enhancementhelp wanted

Repository metrics

Stars
 (45 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I think it would be good if the Readme warned people about false positives.

Even if SUCCESS: Sent termination signal to the process "abc.exe" with PID 123 is returned, there is no guarantee that the process will actually be terminated (see example below) - it's just sending the signal, not more, not less.

λ tasklist /fi "imageName eq boinc.exe"                                     
                                                                            
Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
boinc.exe                    12312 Console                    1     14,108 K
                                                                            
λ taskkill /im "boinc.exe"                                                  
SUCCESS: Sent termination signal to the process "boinc.exe" with PID 12312. 
                                                                            
λ tasklist /fi "imageName eq boinc.exe"                                     
                                                                            
Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
boinc.exe                    12312 Console                    1     16,616 K
                                                                            
λ taskkill /im "boinc.exe" /f                                               
SUCCESS: The process "boinc.exe" with PID 12312 has been terminated.        
                                                                            
λ tasklist /fi "imageName eq boinc.exe"                                     
INFO: No tasks are running which match the specified criteria.              

Just to be clear: the warning should apply to the force option as well: for example, if you are trying to kill a task that depends on a service, you will have to kill the service first.

There are also the usual suspects, of course: insufficient permissions, unkillable system processes, faulty driver processes, etc. All in all, you should probably always check whether the process you tried to kill was actually killed.

PS: Just in case anyone wants to parse the taskkill output to report info, success, errors, etc. in a more user friendly way: please note that these messages are i18n'ed (for example, in English: SUCCESS: ..., in German: ERFOLGREICH: ...).

PPS: It might be worth investigating what the pros and cons of using taskkill compared to wmic or Stop-Process are. Perhaps there's a better way to kill stuff on Windows ... I only know for a fact that shutdown /t 0 /f /r is very reliable when it comes to killing processes. Unfortunately, however, it has terrible performance. :/

Contributor guide