与 AuthorizationExecuteWithPrivileges 的双向通信
我需要使用 AuthorizationExecuteWithPrivileges,将一些数据发送到其标准输入,并在标准输出上读取回复。我可以成功执行辅助工具并通过 communicationsPipe 读取其标准输出,但如果我写入其标准输入,则必须关闭文件描述符才能发送 EOF,否则辅助工具将无限期等待。由于返回的只是一个打开用于读写的文件描述符,我如何关闭写入端,但保持读取端打开?
I need to execute a helper tool with AuthorizationExecuteWithPrivileges, send some data to its stdin, and read a reply on stdout. I can successfully execute the helper tool and read its stdout via the communicationsPipe, but if I write to its stdin I have to close the file descriptor to send an EOF, otherwise the helper tool waits indefinitely. Since all that's returned is a file descriptor opened for reading and writing, how do I just close the write end, but keep the read end open?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 EOF(请参阅 EOF 的 stdin.h 定义)写入 stdin。应该可以做到这一点。您还可以通过命名管道或套接字与辅助工具进行通信,但辅助工具必须支持这一点。
You could write an EOF (see stdin.h define of EOF) to the stdin. That should do it. You could also communicate with your helper tool via named pipes or sockets, though the helper tool would have to support that.