Thread: App termination > Task Manager

  1. #1
    INSANE INSIDE ekosix's Avatar
    Join Date
    May 2010
    Location
    Rio de Janeiro, Brazil
    Posts
    44

    Question App termination > Task Manager

    Hey, I have a little doubt:
    Code:
    int main()
    {
        while(true)
            {
                // do something in a infinite loop
            }
        // call last_function()
        return 0;
    }
    As I have an infinite loop, my app wouldn't terminate by itself... of course...
    But, if I terminate it through Windows Task Manager, will the "last_function()" be called?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Seems like the sort of thing that wouldn't take more than 5 minutes for you to try yourself.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    INSANE INSIDE ekosix's Avatar
    Join Date
    May 2010
    Location
    Rio de Janeiro, Brazil
    Posts
    44
    Yeah, you're right...
    I tested it with this code:
    Code:
    #include <iostream>
    #include <fstream>
    #include <Windows.h>
    
    using namespace std;
    
    int main(void)
    {
    	while(true)
    	{
    		Beep(500, 500);
    		Sleep(2000);
    	}
    	fstream stream;
    	stream.open("text.txt");
    	stream << "IT WORKS!";
    
    	return 0;
    }
    And when I terminated it with Task Manager, the app didn't write to file.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    So, now you know NOT to write programs you can't exit.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. available memory from task manager
    By George2 in forum Tech Board
    Replies: 10
    Last Post: 01-18-2008, 02:32 AM
  2. Task Manager
    By ~Kyo~ in forum Windows Programming
    Replies: 3
    Last Post: 06-07-2005, 10:46 PM
  3. task manager
    By cerin in forum Tech Board
    Replies: 3
    Last Post: 05-09-2005, 06:40 PM
  4. Windows Task Manager
    By Driveway in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-26-2002, 11:43 AM
  5. Windows Task Manager
    By 1234567890 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 08-05-2002, 06:17 AM

Tags for this Thread