test cases/windows/26 global crt value/subprojects/liba/liba.c
raw| 1 | #include <stdlib.h> |
| 2 | #include <fcntl.h> |
| 3 | #include <io.h> |
| 4 | #include <assert.h> |
| 5 | |
| 6 | __declspec (dllexport) |
| 7 | int |
| 8 | liba_get_fd (void) |
| 9 | { |
| 10 | int ret; |
| 11 | |
| 12 | int fd = _open ("NUL", _O_BINARY | _O_NOINHERIT | _O_WRONLY, 0); |
| 13 | assert (fd >= 0); |
| 14 | |
| 15 | if (_dup2 (fd, 500) != 0) |
| 16 | exit (77); /* skip */ |
| 17 | |
| 18 | ret = _close (fd); |
| 19 | assert (ret == 0); |
| 20 | |
| 21 | return 500; |
| 22 | } |