* nix中选择和exceptfds / errorfds语义 [英] *nix select and exceptfds/errorfds semantics

查看:281
本文介绍了* nix中选择和exceptfds / errorfds语义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

href=\"http://www.opengroup.org/onlinepubs/007908775/xsh/select.html\">选择系统调用的

The select syscall takes 3 filedescriptor sets for watching fds for readable/writeable and "exceptions" on filedescriptor.

我的选择手册页没有说明太多关​​于 exceptfd 描述符集。什么是它的用途;可以并将它文件描述符通知什么样的异常?

My select man page doesn't state much about the exceptfd descriptor set. What is it used for; what kind of exceptions can and will it notify on file descriptors?

我假设这可以为描述符类型不同......不管它是TCP套接字,管道,一个tty等)。有没有人有更多的信息是什么样的错误选择可以在不同种类的描述符的报告?

I'm assuming this can be different for the descriptor type... whether it's a TCP socket, a pipe, a tty , etc.). Does anyone have more info on what kind of errors select can report on the different kinds of descriptors?

推荐答案

人们有时认为的 exceptfds 的是需要检测错误,但是这是一种误解。错误会在 readfds 的被标记。尽管POSIX需要它(甚至调用参数的 errorfds 的),它依赖于OS上的错误是否也被标记在的 exceptfds 的。真的,如果你关心时,才需要该参数的得天独厚的条件的,但很少有任何需要检测的。

It is sometimes thought that exceptfds is needed to detect errors, but that is a misconception. Errors will be flagged in readfds. Although POSIX requires it (and even calls the parameter errorfds), it depends on the OS whether errors are also flagged in exceptfds. Really, this parameter is only needed if you care about exceptional conditions, but only rarely is there any need to detect those.

作为一个特殊的条件取决于那种文件描述符,但到目前为止最常见的用途是在TCP套接字什么资格在这里表示使用了带外数据可被读的recv() MSG_OOB 标记。然而,TCP出的带外数据具有数目怪癖(例如,仅1个字节可以是优秀),并作为结果很少使用。

What qualifies as an exceptional condition depends on the kind of file descriptor, but by far the most common use is on a TCP socket where it indicates that out-of-band data is available to be read using recv() with the MSG_OOB flag. However, TCP out-of-band data has a number of quirks (e.g. only 1 byte can be outstanding) and as a result is rarely used.

在最近的Linux内核的 exceptfds 的时候可以用一定的sysfs属性的变化来检测。该属性的当前值可以通过在 / SYS 读取相应的文件中读取和选择()上文件描述符将标记的 exceptfds 的当属性变化。然而,这目前仅适用于某些属性,并为安装的变化(的/ proc /坐骑)。

In recent Linux kernels exceptfds can be used to detect when certain sysfs attributes change. The current value of the attribute can be read by reading the appropriate file under /sys, and a select() on the file descriptor will flag exceptfds when the attribute changes. However this currently only works for some of the attributes, and for mount changes (/proc/mounts).

也有一些设备驱动程序会标志某些特定设备的条件下,使用的 exceptfds

Also some device drivers will flag certain device-specific conditions using exceptfds.

这篇关于* nix中选择和exceptfds / errorfds语义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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