<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic POLLNORM persists on empty-pipe in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pollnorm-persists-on-empty-pipe/m-p/2563160#M919014</link>
    <description>Hello:&lt;BR /&gt;&lt;BR /&gt;Can someone help me with why poll(2) returns with POLLNORM set even after the pipe is emptied (on HP-UX 11.00):&lt;BR /&gt;&lt;BR /&gt;===== Test Case Begins =======&lt;BR /&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;#include &lt;LIMITS.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;POLL.H&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;    pid_t pid, pfd[2]; &lt;BR /&gt;    char lineCount[BUFSIZ], mybuf[PIPE_BUF]; &lt;BR /&gt;    int n, nbytes, pass; &lt;BR /&gt;    n = nbytes = pass = 0; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    pipe(pfd);&lt;BR /&gt;&lt;BR /&gt;    if ( (pid = fork()) &amp;lt; 0 ) {&lt;BR /&gt; perror("main: ");&lt;BR /&gt;    }&lt;BR /&gt;    else if (pid &amp;gt; (pid_t)0)  /* parent */&lt;BR /&gt;    {&lt;BR /&gt; sleep(5);&lt;BR /&gt; close(pfd[1]);&lt;BR /&gt;&lt;BR /&gt; while ( poll_for_readability( pfd[0] ) )&lt;BR /&gt; {&lt;BR /&gt;     pass++; &lt;BR /&gt;     sprintf(lineCount, "%d:", pass);&lt;BR /&gt;     n = strlen(lineCount);  &lt;BR /&gt;     write(STDOUT_FILENO, lineCount, n);&lt;BR /&gt;&lt;BR /&gt;     nbytes = read(pfd[0], mybuf, PIPE_BUF);&lt;BR /&gt;     if (nbytes)&lt;BR /&gt;  write(STDOUT_FILENO, mybuf, nbytes);&lt;BR /&gt;     else&lt;BR /&gt;  write(STDOUT_FILENO, "No data for this pass\n", 22);&lt;BR /&gt;&lt;BR /&gt;     mybuf[0] = '\0';&lt;BR /&gt;        nbytes = 0; &lt;BR /&gt;&lt;BR /&gt;     waitpid(pid, NULL, WNOHANG);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;    }&lt;BR /&gt;    else  /* child */&lt;BR /&gt;    {&lt;BR /&gt; close(pfd[0]);&lt;BR /&gt; write(pfd[1], "Hello World\n", 12);&lt;BR /&gt; close(pfd[1]);&lt;BR /&gt;    }&lt;BR /&gt;  &lt;BR /&gt;    return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;int poll_for_readability(int sfd)&lt;BR /&gt;{&lt;BR /&gt; struct pollfd fds;&lt;BR /&gt; int fdCount = 0;&lt;BR /&gt;&lt;BR /&gt; fds.fd  = sfd;&lt;BR /&gt; fds.events = POLLNORM;&lt;BR /&gt; fds.revents = 0;  &lt;BR /&gt;&lt;BR /&gt; if ( (fdCount = poll(&amp;amp;fds, 1, 0)) &amp;lt; 0 )&lt;BR /&gt; {&lt;BR /&gt;     perror("poll failed");&lt;BR /&gt;     exit(1); &lt;BR /&gt; }&lt;BR /&gt; else if (fds.revents&amp;amp;(POLLERR|POLLHUP|POLLNVAL))&lt;BR /&gt;     return 0; &lt;BR /&gt; else if (fds.revents&amp;amp;POLLNORM)&lt;BR /&gt;     return 1;&lt;BR /&gt; else&lt;BR /&gt;     return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;===== Test Case Ends =======&lt;BR /&gt;&lt;BR /&gt;                 Thanks,&lt;BR /&gt;                 Kiran&lt;/SYS&gt;&lt;/SYS&gt;&lt;/POLL.H&gt;&lt;/STDIO.H&gt;&lt;/LIMITS.H&gt;&lt;/UNISTD.H&gt;</description>
    <pubDate>Wed, 08 Aug 2001 04:37:59 GMT</pubDate>
    <dc:creator>Kiran N. Mehta</dc:creator>
    <dc:date>2001-08-08T04:37:59Z</dc:date>
    <item>
      <title>POLLNORM persists on empty-pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pollnorm-persists-on-empty-pipe/m-p/2563160#M919014</link>
      <description>Hello:&lt;BR /&gt;&lt;BR /&gt;Can someone help me with why poll(2) returns with POLLNORM set even after the pipe is emptied (on HP-UX 11.00):&lt;BR /&gt;&lt;BR /&gt;===== Test Case Begins =======&lt;BR /&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;#include &lt;LIMITS.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;POLL.H&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;    pid_t pid, pfd[2]; &lt;BR /&gt;    char lineCount[BUFSIZ], mybuf[PIPE_BUF]; &lt;BR /&gt;    int n, nbytes, pass; &lt;BR /&gt;    n = nbytes = pass = 0; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    pipe(pfd);&lt;BR /&gt;&lt;BR /&gt;    if ( (pid = fork()) &amp;lt; 0 ) {&lt;BR /&gt; perror("main: ");&lt;BR /&gt;    }&lt;BR /&gt;    else if (pid &amp;gt; (pid_t)0)  /* parent */&lt;BR /&gt;    {&lt;BR /&gt; sleep(5);&lt;BR /&gt; close(pfd[1]);&lt;BR /&gt;&lt;BR /&gt; while ( poll_for_readability( pfd[0] ) )&lt;BR /&gt; {&lt;BR /&gt;     pass++; &lt;BR /&gt;     sprintf(lineCount, "%d:", pass);&lt;BR /&gt;     n = strlen(lineCount);  &lt;BR /&gt;     write(STDOUT_FILENO, lineCount, n);&lt;BR /&gt;&lt;BR /&gt;     nbytes = read(pfd[0], mybuf, PIPE_BUF);&lt;BR /&gt;     if (nbytes)&lt;BR /&gt;  write(STDOUT_FILENO, mybuf, nbytes);&lt;BR /&gt;     else&lt;BR /&gt;  write(STDOUT_FILENO, "No data for this pass\n", 22);&lt;BR /&gt;&lt;BR /&gt;     mybuf[0] = '\0';&lt;BR /&gt;        nbytes = 0; &lt;BR /&gt;&lt;BR /&gt;     waitpid(pid, NULL, WNOHANG);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;    }&lt;BR /&gt;    else  /* child */&lt;BR /&gt;    {&lt;BR /&gt; close(pfd[0]);&lt;BR /&gt; write(pfd[1], "Hello World\n", 12);&lt;BR /&gt; close(pfd[1]);&lt;BR /&gt;    }&lt;BR /&gt;  &lt;BR /&gt;    return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;int poll_for_readability(int sfd)&lt;BR /&gt;{&lt;BR /&gt; struct pollfd fds;&lt;BR /&gt; int fdCount = 0;&lt;BR /&gt;&lt;BR /&gt; fds.fd  = sfd;&lt;BR /&gt; fds.events = POLLNORM;&lt;BR /&gt; fds.revents = 0;  &lt;BR /&gt;&lt;BR /&gt; if ( (fdCount = poll(&amp;amp;fds, 1, 0)) &amp;lt; 0 )&lt;BR /&gt; {&lt;BR /&gt;     perror("poll failed");&lt;BR /&gt;     exit(1); &lt;BR /&gt; }&lt;BR /&gt; else if (fds.revents&amp;amp;(POLLERR|POLLHUP|POLLNVAL))&lt;BR /&gt;     return 0; &lt;BR /&gt; else if (fds.revents&amp;amp;POLLNORM)&lt;BR /&gt;     return 1;&lt;BR /&gt; else&lt;BR /&gt;     return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;===== Test Case Ends =======&lt;BR /&gt;&lt;BR /&gt;                 Thanks,&lt;BR /&gt;                 Kiran&lt;/SYS&gt;&lt;/SYS&gt;&lt;/POLL.H&gt;&lt;/STDIO.H&gt;&lt;/LIMITS.H&gt;&lt;/UNISTD.H&gt;</description>
      <pubDate>Wed, 08 Aug 2001 04:37:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pollnorm-persists-on-empty-pipe/m-p/2563160#M919014</guid>
      <dc:creator>Kiran N. Mehta</dc:creator>
      <dc:date>2001-08-08T04:37:59Z</dc:date>
    </item>
  </channel>
</rss>

