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