Before your program does exit(0);

This is a discussion on Before your program does exit(0); within the C Programming forums, part of the General Programming Boards category; What and, How do you check before your program does exit(1); to free resource you used - socket, memory... - ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    1

    Question Before your program does exit(0);

    What and, How do you check before your program does exit(1);
    to free resource you used - socket, memory... - completely?

    Here is my code using exit(1);
    as you see newfd is socket id.

    Code:
                            switch(iFno)
                            {
                                    case 1:
                                            if(!IPcheck(newfd, psIP, psAstr[0])) {
                                                    exit(1);
                                            }
                                            WorkFno1(newfd, psData, psAstr, z);
                                            break;
    
                                    case 2:
                                            if(!IPcheck(newfd, psIP, psAstr[1])) {
                                                    exit(1);
                                            }
                                            WorkFno2(newfd, psData, psAstr, z);
                                            break;
    
                                    case 2100:
                                            if(!IPcheck(newfd, psIP, psAstr[3])) {
                                                    exit(1);
                                            }
                                            WorkFno2100(newfd, psData, psAstr, z);
                                            break;
    
                                    default:
                                            //Format Error
                                            HonSend(newfd, "1,0\n");
                                            shutdown(newfd,2);
                            }
    Thanks for reading.

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Code:
    <headers>
    
    int main ( void )
    {
    	/* code */
    	close();
    	return 0;
    }
    
    int close ( void )
    {
    	/* free stuff */
    	exit(1)
    }
    The world is waiting. I must leave you now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 10:17 PM
  2. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21