Microsoft played here safely. In their article “Creating a child process with redirected inputs and outputs,” they say:
The remaining open handles are cleared when this process is completed. Explicitly close handles to avoid resource leaks in a larger application.
It is completely useless. What pens? In which process?
I want to get around him.
When a handle is created in the parent process using SECURITY_ATTRIBUTES.bInheritHandle = TRUE , the child process can see and use it, and the handle has the same value and access rights in both processes.
But is this the same descriptor, or is it a copy that has the same numerical representation?
If I pass the hRead handle hRead child process so that it can read from the pipe and the child process closes the handle, do I also need to close it from the parent process? Would he wipe the handset out of the child process?
My experiments show that CloseHandle returns success when trying to close the hRead descriptor hRead to the descendant after the child closed it. That says a lot about yes, you have to close it. However, I would appreciate more solid advice.
GSerg
source share