c++ - CreateProcess handling -


i use windows api createprocess function. in msdn manual it, have found

if function succeeds, sure call closehandle function close hprocess , hthread handles when finished them. otherwise, when child process exits, system cannot clean process structures child process because parent process still has open handles child process.

so should this?

the situation process started , there no track of life. force me make thread, process created , thread wait using, example waitforsingleobject, until process dead, handles released?

you don't have wait child process finish, have closehandle when you no longer need handle.

the reason may want keep handle process after process has finished. may want check return status, example. long have handle it, windows can't clean after it.

but if don't care anymore child does, close handle , move on.

if care, call waitforsingleobject , give handle got createprocess. or call registerwaitforsingleobject (again passing process handle) callback function called when process ends.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -