c++ - DuplicateHandle(), use in first or second process? -
itemprop = "text">
The Windows API Duplicate Handle () object handles need to be repeated and handle the basic process and the second process you use duplicate handles Want to do
I am assuming that if I have two unreserved procedures, then I can say duplicate handles in any one, as long as I had the necessary handles available?
My question is about using a pipe to communicate between two processes to achieve this with an event.
In the first process I want CreateEvent () I now want to use WaitForSingleObject () in the second process.
If I try to duplicate the handles in the first process, then I will need to send the first process through the pipes to the first process, duplicate the handle and then handle the second process?
Alternatively, I can handle the first process and start sending the second process by handling the event and duplicate it there.
What is the reason that I should choose one on another?
To add a wrinkle, the event handle is actually inherited from the original process, which is actually called the first process (which is a CGI application). If this event was handled with HANDLE_DO_NOT_DUPLICATE (similar something), then I can actually use DuplicateHandle () to copy it for the second process
Answer:?
Well I can create a new NAMED event in the first process and it has been suggested as a second process, but I am trying to duplicate the event that is in the parent of the first process Was formed and proceeded further for the second process. This event is not a named event, so I have to use duplicate handles ().
I am using a pipe for IPC. I'm realizing that DuplicateHandle () will be called in the first process when sent to the second process because the event handle is out of context.
hProcPseudo = GetCurrentProcess () // Then the phone either: lpRealHandle = OpenProcess (PROCESS_DUP_HANDLE, 0, HPCsuoduo) // it fails with GetLastError = 87 - the parameter is incorrect ??? // PROCESS_ALL_ACCESS with the same thing ?? // or Elariti = Duplikethandl (Acpisisiudio, Acpisisisudio, Acpiarsisiudio, Elpiarielacandl, Diupielaisiasaamsisias, 0, 0) // if I can duplicate your event used the first thread I: Elariti = Duplikethandl (Aceloelpisisis, Acivent, Elpiarielhandle, Acdiupiiant, Diupielaielasamasisisis , 0, 0) The second process is duplicateHandle () converted
hProcPseudo = 4294967295
Converts your handle with wide
hProcess = 152
Then I handle this process through the first piped pipe. In the first process (where the event handle is valid) I handle the phone duplicate:
DuplicateHandle (hFirstProcess, hEvent, hSecondProc, hDupEvent, DUPLICATE_SAME_ACCESS, 0, 0) Unfortunately, I get an error:
Duplicate Handle HPPFGGI Gallest Error = 6 - The Handle Is Invalid I
Further Investigations (HFirstProcus Replacement) indicate that this HScound Process Is that invalid ?!
Big Mystery
Use for one or IPC, it should work reliably for your purpose. If you need to wait, use the designated wait handle.
Otherwise, I choose to handle duplicate handles in the second process to properly set handle ownership.
Comments
Post a Comment