enter image description hereI am using a Mac and I use Macvim for programming. If my program happens to go into an infinite loop and I have to quit Macvim and restart it due to this the program will restart but the program process keeps running. I realized this when I opened up my activity monitor and see "program foo" is still running at about 99% cpu usage! I can easily shut down the process from activity monitor but is there a way to prevent this? Thanks in advance for any suggestions. Test is the file the loop went into. I created it to show an example.

  • The process from the program you were working is not quitting properly? or A macvim process is not quitting properly? More specifics? If its the program you're writing, fix your code maybe, so as to not cause an infinite loop? – TheIrishGuy Feb 21 '12 at 14:42
  • Thanks. I am not worried about the loop, I understand fixing an infinite loop. My issue is the process for the program continues to show in activity monitor even after i quite Macvim due to an infinite loop. – Gmenfan83 Feb 21 '12 at 14:51
  • But when you say "the program", is "the program" MacVim or the program you are writing? – Daniel Feb 21 '12 at 17:07
  • If the program i am coding goes into an infinite loop due to an error i must quit Macvim. Even after i quit Macvim the program that went into the loop still shows up in Acitvity monitor and is taking up 99% CPU. I know the easy fix is to not cause an infinite loop but they happen. I can shut the program process down via Activity monitor but i wish the process would terminate once i quit Macvim. Making sense? – Gmenfan83 Feb 21 '12 at 17:44
  • When i say "the program" it is the program i am writing, obviously in Macvim. BUT activity monitor will only show the file name and not Macvim. Example Activity monitor would say "foo.cpp" 99% CPU. – Gmenfan83 Feb 21 '12 at 17:49

MacVim forks (spawns a new process) to launch external processes, but it waits for the external process to return before resuming execution. Thus, killing MacVim simply detaches the child process (your program) from MacVim and attaches it to the main process running, in essence, OS X on the whole.

You have to quit, or Force Quit, your program explicitly in order to kill it.

It's also very likely that if you kill your program, and NOT MacVim, you can continue using MacVim without issue.

| improve this answer | |
  • Would you happen to know which command would kill the program without quitting Macvim? I can only find documentation on saving and quitting etc.? – Gmenfan83 Feb 21 '12 at 20:05
  • 1
    If pressing control c doesn't work, you can select and kill your app via Activity Monitor first, and then MacVim should start working again. – Jason Salaz Feb 21 '12 at 20:40
  • 1
    From the Terminal ps auxr | grep test | head -1 | awk {'print$2'} | xargs -t kill -9 where test is the name of your application. No need for Activity Monitor. – afragen Feb 21 '12 at 22:22
  • 3
    @afragen I'll do you one better: killall -s KILL test, where test is the name of your application. – Jason Salaz Feb 21 '12 at 23:12
  • @JasonSalaz unless you have other processes with that name... – Daniel Feb 21 '12 at 23:31

You must log in to answer this question.

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