|
fstat函数运行不正常,如下函数所示,在redhat 9中编译运行最后打印值是5,但是在redhat adv3 中编译运行时总是零,请问fstat函数用不了是由于什么方面的问题,如何解决,谢谢。
另不知发文是不是发错了版面,如果发错了实在抱歉。
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
main()
{
int fd[2];
int writenum;
struct stat statbuf;
if( pipe(fd)<0)
perror("pipe message");
writenum=write(fd[1],"hello",5);
if(writenum==-1)
perror("the write:");
printf("the writenum:%d\n",writenum);
fstat(fd[0],&statbuf);
printf("the size:%d,\n",statbuf.st_size);
} |
|