...
| Code Block | ||
|---|---|---|
| ||
#include <stdio.h>
#include <stdlib.h>
void exit1(void) {
/* ...cleanup code... */
return;
}
void exit2(void) {
if (/* condition */) {
/* ...more cleanup code... */
exit(0);
}
return;
}
int main(void) {
if (atexit(exit1) != 0) {
/* Handle Errorerror */
}
if (atexit(exit2) != 0) {
/* Handle Errorerror */
}
/* ...program code... */
exit(0);
}
|
...
| Code Block | ||
|---|---|---|
| ||
#include <stdio.h>
#include <stdlib.h>
void exit1(void) {
/* ...cleanup code... */
return;
}
void exit2(void) {
if (/* condition */) {
/* ...more cleanup code... */
}
return;
}
int main(void) {
if (atexit(exit1) != 0) {
/* Handle Errorerror */
}
if (atexit(exit2) != 0) {
/* Handle Errorerror */
}
/* ...program code... */
exit(0);
}
|
...
| Code Block | ||
|---|---|---|
| ||
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
jmp_buf env;
int val;
void exit1(void) {
/* ... */
longjmp(env, 1);
}
int main(void) {
if (atexit(exit1) != 0) {
/* handleHandle error */
}
/* ... */
if (setjmp(env) == 0) {
exit(0);
}
else {
return 0;
}
}
|
...
| Code Block | ||
|---|---|---|
| ||
#include <stdlib.h>
void exit1(void) {
/* ... */
return;
}
int main(void) {
if (atexit(exit1) != 0) {
/* handleHandle error */
}
/* ... */
exit(0);
}
|
...