1.open 函数以非缓冲打开文件,返回int型文件描述符;
2.fdopen 函数用于在一个已经打开的文件描述符上打开一个流,返回文件指针;
/* open the command file for reading (non-blocked) - O_TRUNC flag cannot be used due to errors on some systems */
/* NOTE: file must be opened read-write for poll() to work */
if((command_file_fd=open(command_file,O_RDWR | O_NONBLOCK))<0)
{
return ERROR;
}
/* re-open the FIFO for use with fgets() */
if((command_file_fp=(FILE *)fdopen(command_file_fd,"r"))==NULL)
{
return ERROR;
}
3.fopen 打开一个流,返回文件指针。