我有一个小型客户端程序,它使用 rsh 来获取文件的 inode 号。我面临的问题是 rsh 命令正在执行,但父级没有读取输出。
如果我运行任何命令,比如在本地执行的“ls”,我可以看到输出。
/* Child */
close pipe[0];
dup2(pipe[1],STDOUT_FILENO);
execv("/usr/bin/rsh","ls","-i","a.txt");
/* Parent */
close pipe[1]
bytes = read pipe[0]
/* bytes always is 0. But if I have ls executed by child,
* I can see full output */