Handling of asynchronous events---reference
副标题[/!--empirenews.page--]
http://www.win.tue.nl/~aeb/linux/lk/lk-12.html 12.?Handling of asynchronous eventsOne wants to be notified of various events,like data that has become available,files that have changed,and signals that have been raised. FreeBSD has the nice?API. Let us discuss the Unix/Linux situation. It is easy to wait for a single event. Usually one does a (blocking)? Many mechanisms exist to wait for any of a set of events,or just to test whether anything interesting happened. 12.1?O_NONBLOCKIf the? A nonblocking open is useful (i) in order to obtain a file descriptor for subsequent use when no I/O is planned,e.g. for? O_NOACCESSAn obscure Linux feature is that one can open a file with the O_NOACCESS flag (defined as 3,where O_RDONLY is 0,O_WRONLY is 1 and O_RDWR is 2). In order to open a file with this mode,one needs both read and write permission. This had the same purpose: announce that no reading or writing was going to be done,and only a file descriptor for ioctl use was needed. (Used in LILO,fdformat,and a few similar utilities.) People would love to have this facility also for directories,so that one could do a? 12.2?selectThe? int select(int nfds,fd_set *restrict readfds,fd_set *restrict writefds,fd_set *restrict errorfds,struct timeval *restrict timeout); It allows one to specify three sets of file descriptors (as bit masks) and a timeout. The call returns when the timeout expires or when one of the file descriptors in There are two select system calls. The old one uses a parameter block,the new one uses five parameters. Otherwise they are equivalent. 12.3?pselectThe? int gotsignal = 0; Now if one wants to wait for either a signal or some event on a file descriptor,then testing the flag and if it is not set calling? The call? int pselect(int nfds,const struct timespec *restrict timeout,const sigset_t *restrict sigmask); with a sixth parameter? sigset_t origmask; as an atomic action. Now one can block the signals of interest until the call of? This function uses a struct timespec (with nanoseconds) instead of a struct timeval (with microseconds),and does not update its value on return. The self-pipe trickBefore the introduction of? The system call(编辑:南平站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- How to allow/block PING on Linux server – IPTables rul
- 鸭嘴兽泰瑞在哪里攻略(我可信赖的密探1-10关,三星通关视频
- linux – 使用systemd服务单元的Restartamp;RestartSec或使
- ipad mini和ipad3有什么区别 ipad mini解析
- linux – 收集和集中来自许多服务器的信息,有点像Puppet的因
- node.js中的fs.lstatSync方法使用说明
- 四大特色带你看Linux内核5.6
- 叉叉连萌助手使用教程
- Linux内核分析 - 网络[十三]:校验和
- linux-kernel – IO-APIC级别与PCI-MSI-X之间的差异