typedef struct _SECURITY_ATTRIBUTES {// sa
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle; // If this member is TRUE, the new process inherits the handle
} SECURITY_ATTRIBUTES;
BOOL CreatePipe(
PHANDLE hReadPipe, // pointer to read handle
PHANDLE hWritePipe, // pointer to write handle
LPSECURITY_ATTRIBUTES lpPipeAttributes, // pointer to security attributes
DWORD nSize // pipe size
);
创建管道的时候,如果CreatePipe的第三个参数lpPipeAttributes = NULL或者SECURITY_ATTRIBUTES.bInheritHandle = FALSE,会导致新创建的CMD进程不能继承管道HANDLE,所以导致ReadFile阻塞的问题.
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle; // If this member is TRUE, the new process inherits the handle
} SECURITY_ATTRIBUTES;
BOOL CreatePipe(
PHANDLE hReadPipe, // pointer to read handle
PHANDLE hWritePipe, // pointer to write handle
LPSECURITY_ATTRIBUTES lpPipeAttributes, // pointer to security attributes
DWORD nSize // pipe size
);
创建管道的时候,如果CreatePipe的第三个参数lpPipeAttributes = NULL或者SECURITY_ATTRIBUTES.bInheritHandle = FALSE,会导致新创建的CMD进程不能继承管道HANDLE,所以导致ReadFile阻塞的问题.