您的位置:首页 > 运维架构

why open returns zero?

2015-12-27 17:56 274 查看
在试验open代码的时候,也犯了和这个哥们一样的错误。

如此低级的错误一定不要再犯了。

点击打开链接

Your conditional is off. Mind the parentheses. It should be:

if ((fd2 = open(logFile, O_RDWR |O_APPEND | O_CREAT , 0666)) == -1)
//                                                        ^^^    ^^^

Sometimes it might be best not to outsmart yourself:

int fd = open(...);

if (fd == -1) { DieWithError(); }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: