Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
    
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 Lawson 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
show 1 more comment

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
    
I see, thank you for the detailed answer! –  Gmenfan83 Feb 21 '12 at 19:56
    
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
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.