Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
#include <stdio.h>
#include <stdlib.h>


void exit1(void) {
if(expr)
       exit();
       //clean up and ready program for closing
           ...
}

int main (void) {

    atexit(exit1);
    ...
     //program code
     exit();
     return 0;
}

Compliant Code

...

Code Block
bgColor#ccccFF
#include <stdio.h>
#include <stdlib.h>

#include <stdio.h>
#include <stdlib.h>

void exit1(void) {
if(expr)
       _Exit();
       //clean up and ready program for closing
           ...
}

int main (void) {

    atexit(exit1);
    ...    
     //program code
     exit();
     return 0;
}

The call to _Exit() will immediately terminate the program and no undefined behavior will happen like in the non compliant example.

...