简体   繁体   English

创建一个进程并重定向其输入/输出,并且不继承套接字句柄

[英]create a process and redirect its input/output and dont inherit socket handles

Is it possible to create a process and redirect its input and output but set the child not to inherit socket handles ? 是否可以创建进程并重定向其输入和输出,但将子级设置为不继承套接字句柄? ( maybe pinvoke with CreateProcess somehow ) If I use UseShellExecute = true the child doesn't inherit the socket but I cant redirect output. (也许以某种方式与CreateProcess一起调用)如果我使用UseShellExecute = true,则子级不会继承套接字,但无法重定向输出。

CreateProcess takes a STARTUPINFO as one of its parameters. CreateProcessSTARTUPINFO作为其参数之一。 Three of the fields in this struct are the in, out and error handles. 此结构中的三个字段是输入,输出和错误句柄。

Don't forget to set the STARTF_USESTDHANDLES flag. 不要忘记设置STARTF_USESTDHANDLES标志。

Edit: So you have to set the bInheritHandles parameter. 编辑:因此,您必须设置bInheritHandles参数。 See this page for more information about inherited handles. 有关继承的句柄的更多信息,请参见此页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM