| 94 | } |
| 95 | |
| 96 | int common_pipe::close(int *exit_code) |
| 97 | { |
| 98 | if (!opened()) |
| 99 | return 0; // nothing to do |
| 100 | // Close the pipe to process: |
| 101 | fclose(file_); |
| 102 | file_ = nullptr; |
| 103 | // Wait for the process to finish |
| 104 | if (auto r = WaitForSingleObject(hProcess, INFINITE); r != WAIT_OBJECT_0) { |
| 105 | CloseHandle(hThread); |
| 106 | CloseHandle(hProcess); |
| 107 | return ECHILD; |
| 108 | } |
| 109 | // Retrieve the exit code |
| 110 | if (exit_code != nullptr) { |
| 111 | if (BOOL r = GetExitCodeProcess(hProcess, (LPDWORD)exit_code); !r) { |
| 112 | auto err = GetLastError(); |
| 113 | CloseHandle(hThread); |
| 114 | CloseHandle(hProcess); |
| 115 | return err; |
| 116 | } |
| 117 | } |
| 118 | CloseHandle(hThread); |
| 119 | CloseHandle(hProcess); |
| 120 | return 0; |
| 121 | } |
| 122 | #endif // _WIN32 implementtion |
| 123 | |
| 124 | #if defined(__linux) || defined(__APPLE__) |
nothing calls this directly
no outgoing calls
no test coverage detected