MCPcopy Create free account
hub / github.com/catboost/catboost / Duplicate2Posix

Method Duplicate2Posix

util/system/file.cpp:626–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624}
625
626int TFileHandle::Duplicate2Posix(int dstHandle) const noexcept {
627 if (!IsOpen()) {
628 return -1;
629 }
630#if defined(_win_)
631 FHANDLE dupHandle = Duplicate();
632 if (dupHandle == INVALID_FHANDLE) {
633 _set_errno(EMFILE);
634 return -1;
635 }
636 int posixHandle = _open_osfhandle((intptr_t)dupHandle, 0);
637 if (posixHandle == -1) {
638 CloseHandle(dupHandle);
639 return -1;
640 }
641 if (dup2(posixHandle, dstHandle) == -1) {
642 dstHandle = -1;
643 }
644 _close(posixHandle);
645 return dstHandle;
646#elif defined(_unix_)
647 while (dup2(Fd_, dstHandle) == -1) {
648 if (errno != EINTR) {
649 return -1;
650 }
651 }
652 return dstHandle;
653#else
654 #error unsupported platform
655#endif
656}
657
658bool TFileHandle::LinkTo(const TFileHandle& fh) const noexcept {
659#if defined(_unix_)

Callers 3

TOutputCapturerMethod · 0.80
UncaptureMethod · 0.80
ForInputMethod · 0.80

Calls 2

DuplicateFunction · 0.85
dup2Function · 0.50

Tested by

no test coverage detected