MCPcopy Create free account
hub / github.com/Kitware/CMake / kwsysProcessCreateChildHandle

Function kwsysProcessCreateChildHandle

Source/kwsys/ProcessWin32.c:1651–1684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1649}
1650
1651static DWORD kwsysProcessCreateChildHandle(PHANDLE out, HANDLE in, int isStdIn)
1652{
1653 DWORD flags;
1654
1655 /* Check whether the handle is valid for this process. */
1656 if (in != INVALID_HANDLE_VALUE && GetHandleInformation(in, &flags)) {
1657 /* Use the handle as-is if it is already inherited. */
1658 if (flags & HANDLE_FLAG_INHERIT) {
1659 *out = in;
1660 return ERROR_SUCCESS;
1661 }
1662
1663 /* Create an inherited copy of this handle. */
1664 if (DuplicateHandle(GetCurrentProcess(), in, GetCurrentProcess(), out, 0,
1665 TRUE, DUPLICATE_SAME_ACCESS)) {
1666 return ERROR_SUCCESS;
1667 } else {
1668 return GetLastError();
1669 }
1670 } else {
1671 /* The given handle is not valid for this process. Some child
1672 processes may break if they do not have a valid standard handle,
1673 so open NUL to give to the child. */
1674 SECURITY_ATTRIBUTES sa;
1675 ZeroMemory(&sa, sizeof(sa));
1676 sa.nLength = (DWORD)sizeof(sa);
1677 sa.bInheritHandle = 1;
1678 *out = CreateFileW(
1679 L"NUL",
1680 (isStdIn ? GENERIC_READ : (GENERIC_WRITE | FILE_READ_ATTRIBUTES)),
1681 FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, OPEN_EXISTING, 0, 0);
1682 return (*out != INVALID_HANDLE_VALUE) ? ERROR_SUCCESS : GetLastError();
1683 }
1684}
1685
1686DWORD kwsysProcessCreate(kwsysProcess* cp, int index,
1687 kwsysProcessCreateInformation* si)

Callers 1

kwsysProcessCreateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…