|
我在RTLinux3.2+Linux-2.4.20下编写了一个应用 FIFO的程序,非实时模块的代码如下:
int main(int argc,char **argv)
{
int fd_fifo, m, n;
long long data_ret;
FILE *fp_ret;
fp_ret = fopen(argv[1], "a+");
if (fp_ret == NULL)
{
printf("Error: open file %s failed! errno=%d\n",argv[1],errno);
exit(1);
}
fd_fifo = open ("/dev/rtf3", O_RDONLY);
if (fd_fifo < 0)
{
printf("Error: opening /dev/rtf3 fail! \n");
exit(1);
}
for (;;)
{
n = read(fd_fifo, &data_ret, sizeof(long long));
fprintf(stderr,"%Ld\n",data_ret);
fprintf(fp_ret,"%Ld\n",data_ret);
}
fclose(fp_ret);
close(fd_fifo);
return 0;
}
郁闷的是 fprintf(stderr,"%Ld\n",data_ret)能在屏幕上显示正确结果(一些long long类型的数据)
但是 fprintf(fd_ret,"%Ld\n",data_ret); 死活都不向 fd_ret中写数据?
这时什么原因? |
|