linux下怎么判断标准输出是不是被重定向到了文件?

happynxy 2011-07-27 01:28:11
Linux下面,我想判断标准输出/出错是不是被重定向到了文件,换句话说,我想看标准输出/出错是不是定向到了用户的终端上,这个用什么办法呢?

谢谢!!
...全文
249 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
happynxy 2011-07-27
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 zhao4zhong1 的回复:]

st_mode

Bit mask for file-mode information. The _S_IFCHR bit is set if handle refers to a device. The _S_IFREG bit is set if handle refers to an ordinary file. The read/write bits are set accordin……
[/Quote]谢谢!
赵4老师 2011-07-27
  • 打赏
  • 举报
回复
st_mode

Bit mask for file-mode information. The _S_IFCHR bit is set if handle refers to a device. The _S_IFREG bit is set if handle refers to an ordinary file. The read/write bits are set according to the file’s permission mode. _S_IFCHR and other constants are defined in SYS\STAT.H.

happynxy 2011-07-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 luciferisnotsatan 的回复:]

int fstat(int fildes, struct stat *buf)
看看0,1,2三个文件文件描述符的状态
[/Quote]请问看哪个状态可以看出来呢?谢谢~~
luciferisnotsatan 2011-07-27
  • 打赏
  • 举报
回复
int fstat(int fildes, struct stat *buf)
看看0,1,2三个文件文件描述符的状态
ganjianh8 2011-07-27
  • 打赏
  • 举报
回复
你用标准输出都是用std::cout吧
建议你看看msdn对ostream的说明
以及ostream_withassign::ostream_withassign会对你有用

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧