2

I wrote a simple hello world program that should print hello to the console. I compiled it using gcc. Once I tried to run the .exe file it created a little blue spinner next to my mouse pointer and it doesn't go away. I've tried to kill the process using taskkill (I'm on windows7) but it's not working. Perhaps there's a bug in the code?

Things I've tried:

  • ending the process from windows task manager

  • taskkill /IM helloworld.exe /f

tl;dr A hello world program won't exit even using taskkill

#include <stdio.h>

int main(){
  printf("Hello world");
  return 0;
}
user59390
  • 21
  • 2
  • 2
    Do you use Avast antivirus? – Blastfurnace Jan 09 '16 at 17:39
  • 2
    Just curious, After you kill the program (if non of the answers work just restart), if you run it again will you get the same result? Because your code is 100% bug free. return 0; from main is supposed to be equivalent to exit (0); – Ankush Jan 09 '16 at 17:39
  • your system is getting slower i guess... just restart it. and try to clean your system. – Sachin Jan 09 '16 at 17:44
  • Ankush, I'm about to restart the computer because it seems that's the only option. There must be a bug in the code. – user59390 Jan 09 '16 at 17:44
  • It's possibly (probably?) the same Avast problem that has been happening to others. It's the same symptoms and it's affecting Visual C++ and gcc users. – Blastfurnace Jan 09 '16 at 17:46
  • See the link from @Blastfurnace. Similarly, if I try tricking Windows into filing an .exe program I made on another Windows machine, Windows Defender will have none of it, and deletes it. – Weather Vane Jan 09 '16 at 17:47
  • Alright I had to reboot. Still don't know why, but could be because of Avast. – user59390 Jan 09 '16 at 17:58
  • Maybe your anti virus doesn't like the program since it closes right away. Try adding a `getch();` before the `return 0;` (and `#include `). This forces your program to be alive until you press return. Therefore the program is waiting for something and not terminating right away... If your program terminates normaly with that modification it's very likely that your anti virus program is the cause of your observation. And by the way: there is nothing wrong with your code. – Lukas Thomsen Jan 09 '16 at 18:53
  • @LukasThomsen: The simplest test is to temporarily disable Avast and build/run the program. – Blastfurnace Jan 09 '16 at 19:50
  • @Blastfurnace: Ah... I didn't read that he's using Avast. You're right in that case... – Lukas Thomsen Jan 09 '16 at 19:53

1 Answers1

-2

Use exit(0); in your program. Don't forget to use include <stdlib.h>

Andy
  • 49,085
  • 60
  • 166
  • 233