How to pass handle to child process

后端 未结 2 725
北海茫月
北海茫月 2021-01-03 07:55

I\'m trying to pass a mutex handle, to a child process trough command line, or any other way.

How can I do that? How do I acess the mutex from the child?

Th

2条回答
  •  清酒与你
    2021-01-03 08:29

    Either create the mutex before creating the child process and make it inheritable (set bInheritHandle to TRUE in the lpMutexAttributes parameter for CreateMutex). This way you can pass the handle in the command line.

    Or use DuplicateHandle and pass the handle via some other mechanism (e.g. use a pipe as STDIN for the child process).

提交回复
热议问题