调用write()的长度为零的后果是什么? [英] What are the consequences of calling write() with zero length?

查看:173
本文介绍了调用write()的长度为零的后果是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux write()函数中处于相当高的级别,它会过滤掉写入0个长度缓冲区的请求。这是有道理的。谁想要操作系统浪费它的时间钻进层只是为了确定没有工作要做?

At fairly high level in the Linux write() function, it filters out requests for writing 0 length buffers. Which makes sense. Who'd want to the OS wasting it's time drilling through layers only to determine there is no work to be done?

嗯......我。

它与此相关问题;如果握手错误地址(在数据之前在总线上发送)会发出错误,那么发现bit-banged I2C驱动程序会给出一个可能有用的返回码。

It's related to this question; and the discovery that the bit-banged I2C driver will give a potentially useful return code if the address (sent on the bus before data) will give an error if the handshaking is wrong.

可以在地址之后发送虚拟数据,但不能发送我正在使用的设备。 (也许我会尝试阅读......)。

One could send dummy data after the address, but not with the device I'm using. (Perhaps I'll try a read ...).

所以问题是: 如果内核是什么,会释放什么样的地狱?允许零(0)长度写入?

So the question is: What sort of hell would be unleashed if the kernel were to allow zero (0) length writes?

推荐答案

只是为了关闭,我我会选择Warren Young更新驱动程序和发布补丁的想法(当我得到一个回合 tuit )。

Just for the sake of closure, I'm going with Warren Young's idea of updating the driver and publishing the patch (when I get a round tuit).

这篇关于调用write()的长度为零的后果是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆