Files
RedBear-OS/tests/fcntl/create.c
T
Tibor Nagy d1a424c002 tests: Replace returns with exits in the main functions
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); \
}
```
2019-02-21 12:15:06 +01:00

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);
}
}