LINUX标准io默认都是阻塞的

来源:互联网 发布:淘宝大虫网游店 编辑:程序博客网 时间:2024/05/17 03:42
#include <stdio.h>#include <fcntl.h>#include <unistd.h>int main(){  int s_in, s_out, s_err;  s_in= fcntl(STDIN_FILENO, F_GETFL);  s_out= fcntl(STDOUT_FILENO, F_GETFL);  s_err= fcntl(STDERR_FILENO, F_GETFL);  if (O_NONBLOCK == s_in)     printf("stdin is nonblock\n");  else     printf("stdin is block\n");  if (O_NONBLOCK == s_out)     printf("stdout is nonblock\n");  else     printf("stdout is block\n");  if (O_NONBLOCK == s_err)     printf("stderror is nonblock\n");  else     printf("stderror is block\n");}


原创粉丝点击