关于linux下的缓存机制

在linux下的文件缓存输出机制

1、缓存已满内容输出

2、按照”\n”格式化打印输出

3、进程结束

4、STDERR的输出优先级大于STDOUT,而且STDERR不可以被重定向。[命令除外 2>&1 ]

关于linux下的dup()和dup2()

dup()重定向

int dup(int oldfd);
dup(): uses the lowest-numbered unused descriptor for the new descriptor.以后就可以通过返回的文件描述符操作文件。

dup2()重定向

int dup2(int oldfd, int newfd);
dup2() makes newfd be the copy of oldfd, closing newfd first if neces‐sary, but note the following:

If oldfd is not a valid file descriptor, then the call fails, and newfd is not closed.
If oldfd is a valid file descriptor, and newfd has the same value as
oldfd, then dup2() does nothing, and returns newfd.
dup2()可以通过把newfd的文件描述符返回给指定的文件描述符来重定向到oldfd中。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值