| 597 | #endif |
| 598 | |
| 599 | bool FileIsClosed(int fd) { |
| 600 | #if defined(_WIN32) |
| 601 | // Disables default behavior on wrong params which causes the application to crash |
| 602 | // https://msdn.microsoft.com/en-us/library/ksazx244.aspx |
| 603 | _set_invalid_parameter_handler(InvalidParamHandler); |
| 604 | |
| 605 | // Disables possible assertion alert box on invalid input arguments |
| 606 | _CrtSetReportMode(_CRT_ASSERT, 0); |
| 607 | |
| 608 | int new_fd = _dup(fd); |
| 609 | if (new_fd == -1) { |
| 610 | return errno == EBADF; |
| 611 | } |
| 612 | _close(new_fd); |
| 613 | return false; |
| 614 | #else |
| 615 | if (-1 != fcntl(fd, F_GETFD)) { |
| 616 | return false; |
| 617 | } |
| 618 | return errno == EBADF; |
| 619 | #endif |
| 620 | } |
| 621 | |
| 622 | #if !defined(_WIN32) |
| 623 | void AssertChildExit(int child_pid, int expected_exit_status) { |
no test coverage detected