1
我正在将stdin和stdout的文件描述符重定向到子进程中,如下所示。 现在我想让子进程等待,直到输入描述符中的数据可用。目前,如果数据在输入描述符处不可用,那么子进程需要一些随机值(我猜EOF)并终止。等待来自文件描述符的输入
fd0=open("in1.dat", O_RDWR|O_CREAT);
fd1=open("out1.dat", O_RDWR|O_CREAT);
if(pid==0)
{
dup2(fd0, 0); // redirect input to the file
dup2(fd1, 1); // redirect output to the file
execlp("./flip","flip","new","4",NULL);
}
我几乎不会调用EOF“一些随机值”,尤其是当您将stdin明确设置为空文件时。 – 2011-05-10 02:52:52