d1a424c002
This will allow us to redefine the exit function.
For example:
```
#define exit(code) { \
fprintf(stderr, "%s:%d: exit(%s) in function ‘%s’\n",
__FILE__, __LINE__, #code, __func__); \
_exit(code); \
}
```
16 lines
325 B
C
16 lines
325 B
C
#include <fcntl.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
int main(void) {
|
|
int fd = creat("create.out", 0755);
|
|
if (fd >= 0) {
|
|
write(fd, "Hello World!\n", 13);
|
|
close(fd);
|
|
exit(EXIT_SUCCESS);
|
|
} else {
|
|
write(STDERR_FILENO, "creat failed\n", 13);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|