<HTML ><HEAD ><TITLE >poll()</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ "><LINK REL="HOME" TITLE="The Linux SCSI Generic (sg) HOWTO" HREF="index.html"><LINK REL="UP" TITLE="System calls" HREF="syscalls.html"><LINK REL="PREVIOUS" TITLE="read()" HREF="read.html"><LINK REL="NEXT" TITLE="close()" HREF="close.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The Linux SCSI Generic (sg) HOWTO</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="read.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 7. System calls</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="close.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="POLL">7.4. poll()</H1 ><DIV CLASS="FORMALPARA" ><P ><B >poll(struct pollfd *ufds, unsigned int nfds, int timeout). </B >This call can be used to check the state of a sg file descriptor. It will always respond immediately. Typical usages are to periodically poll the state of a sg file descriptor and to determine why a SIG_IO signal was received.</P ></DIV ><P >For file descriptors associated with sg devices: <P ></P ><UL ><LI ><P > POLLIN one or more responses is awaiting a read()</P ></LI ><LI ><P > POLLOUT command can be sent to write() without causing an EDOM error (i.e. sufficient space on sg's queues)</P ></LI ><LI ><P > POLLHUP SCSI device has been detached, awaiting cleanup</P ></LI ><LI ><P > POLLERR internal structures are inconsistent</P ></LI ></UL ></P ><P >POLLOUT indicates the sg will not block a new write() or SG_IO ioctl(). However it is still possible (but unlikely) that the mid level or an adapter may block (or yield EAGAIN).</P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="read.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="close.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >read()</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="syscalls.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >close()</TD ></TR ></TABLE ></DIV ></BODY ></HTML >