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); \
}
```
17 lines
284 B
C
17 lines
284 B
C
#include <sys/wait.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
|
pid_t pid = fork();
|
|
if (pid == 0) {
|
|
// child
|
|
sleep(1);
|
|
exit(EXIT_SUCCESS);
|
|
} else {
|
|
// parent
|
|
int stat_loc;
|
|
waitpid(pid, &stat_loc, 0);
|
|
}
|
|
}
|