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