HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- POLLNORM persists on empty-pipe
Operating System - HP-UX
1825793
Members
2292
Online
109687
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2001 09:37 PM
08-07-2001 09:37 PM
POLLNORM persists on empty-pipe
Hello:
Can someone help me with why poll(2) returns with POLLNORM set even after the pipe is emptied (on HP-UX 11.00):
===== Test Case Begins =======
#include
#include
#include
#include
#include
#include
int main(void)
{
pid_t pid, pfd[2];
char lineCount[BUFSIZ], mybuf[PIPE_BUF];
int n, nbytes, pass;
n = nbytes = pass = 0;
pipe(pfd);
if ( (pid = fork()) < 0 ) {
perror("main: ");
}
else if (pid > (pid_t)0) /* parent */
{
sleep(5);
close(pfd[1]);
while ( poll_for_readability( pfd[0] ) )
{
pass++;
sprintf(lineCount, "%d:", pass);
n = strlen(lineCount);
write(STDOUT_FILENO, lineCount, n);
nbytes = read(pfd[0], mybuf, PIPE_BUF);
if (nbytes)
write(STDOUT_FILENO, mybuf, nbytes);
else
write(STDOUT_FILENO, "No data for this pass\n", 22);
mybuf[0] = '\0';
nbytes = 0;
waitpid(pid, NULL, WNOHANG);
}
}
else /* child */
{
close(pfd[0]);
write(pfd[1], "Hello World\n", 12);
close(pfd[1]);
}
return 0;
}
int poll_for_readability(int sfd)
{
struct pollfd fds;
int fdCount = 0;
fds.fd = sfd;
fds.events = POLLNORM;
fds.revents = 0;
if ( (fdCount = poll(&fds, 1, 0)) < 0 )
{
perror("poll failed");
exit(1);
}
else if (fds.revents&(POLLERR|POLLHUP|POLLNVAL))
return 0;
else if (fds.revents&POLLNORM)
return 1;
else
return 0;
}
===== Test Case Ends =======
Thanks,
Kiran
Can someone help me with why poll(2) returns with POLLNORM set even after the pipe is emptied (on HP-UX 11.00):
===== Test Case Begins =======
#include
#include
#include
#include
#include
#include
int main(void)
{
pid_t pid, pfd[2];
char lineCount[BUFSIZ], mybuf[PIPE_BUF];
int n, nbytes, pass;
n = nbytes = pass = 0;
pipe(pfd);
if ( (pid = fork()) < 0 ) {
perror("main: ");
}
else if (pid > (pid_t)0) /* parent */
{
sleep(5);
close(pfd[1]);
while ( poll_for_readability( pfd[0] ) )
{
pass++;
sprintf(lineCount, "%d:", pass);
n = strlen(lineCount);
write(STDOUT_FILENO, lineCount, n);
nbytes = read(pfd[0], mybuf, PIPE_BUF);
if (nbytes)
write(STDOUT_FILENO, mybuf, nbytes);
else
write(STDOUT_FILENO, "No data for this pass\n", 22);
mybuf[0] = '\0';
nbytes = 0;
waitpid(pid, NULL, WNOHANG);
}
}
else /* child */
{
close(pfd[0]);
write(pfd[1], "Hello World\n", 12);
close(pfd[1]);
}
return 0;
}
int poll_for_readability(int sfd)
{
struct pollfd fds;
int fdCount = 0;
fds.fd = sfd;
fds.events = POLLNORM;
fds.revents = 0;
if ( (fdCount = poll(&fds, 1, 0)) < 0 )
{
perror("poll failed");
exit(1);
}
else if (fds.revents&(POLLERR|POLLHUP|POLLNVAL))
return 0;
else if (fds.revents&POLLNORM)
return 1;
else
return 0;
}
===== Test Case Ends =======
Thanks,
Kiran
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP