20

I have a small shell script called "k" that i call everytime when i want to reset my complete Development Cycle:

killall node
killall Xcode
killall Terminal

How can i find out the final name of the "Visual Studio Code"-Prozess to kill it also this way?

I've tried:

killall "Visual Studio Code"

No matching processes belonging to you were found

killall "Code"

No matching processes belonging to you were found

Any ideas? I am looking for a generic approach without any manually lookup of PIDs necessary.

This application looks like this in Activity Monitor: enter image description here

4 Answers 4

26

I have Visual Studio Code, version 1.1.1, installed and on my system the following works for me:

kill -9 $(pgrep Electron)

Update: Just tested with Visual Studio Code, version 1.14.1, under macOS 10.12.5 and the above command closes Code and Code Helper that show in Activity Monitor.

PS: killall Electron also works.

5
  • 7
    This is a pretty bad idea considering how many Electron apps exist now. A better plan would be to use $(pgrep Visual Studio Code).
    – DBrown
    Sep 10, 2018 at 0:48
  • 3
    @DBrown, At the time this answer was posted Visual Studio Code could not be killed in that manner because the only process exposed was electron. I no longer have the latest version installed, so I cannot test if the same is still true now as when this answer was originally written. Sep 12, 2018 at 1:00
  • 1
    Ah, fair enough. I tested this particular method with 1.27.1 on OSX 10.13.6, and for a hanging main process this worked very well. Of course in other situations the Electron frontend will persist, but at the very least this will allow users to kill the main sleeping/zombie process and be notified to reopen to a new session. Was this what you experienced with older versions?
    – DBrown
    Sep 12, 2018 at 17:35
  • @DBrown, I want to say it handle everything but I honestly do not remember, as it was 14 months ago, and I do not have the particular system it was run on handy to look back at, if it was still installed. Sep 13, 2018 at 4:00
  • Thanks! This is the only answer that helped me recover vscode without restarting my machine. VScode 1.48.1, Catalina. Aug 25, 2020 at 7:39
7

Alternative for Mac OS (Darwin) is:

osascript -e 'quit app "Visual Studio Code"'
0
3
  • use Activity Monitor to get the process id of "Code" ( -> PID)
  • run ps -ef | grep PID to get the process name as known to the OS
  • run killall <process name>
2
  • thanx, but i am looking for a generic approach without any manually lookup necessary :)
    – itinance
    Jul 19, 2017 at 8:39
  • You only need to do the lookup once, to get the process name (which will be the same the next time)
    – nohillside
    Jul 19, 2017 at 8:48
3

This one is working for me, pkill Electron or pkill Visual Studio Code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .