GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Problem on poll(2) system call
Operating System - HP-UX
1849279
Members
5901
Online
104042
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
Forums
Discussions
back
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
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
10-30-2008 01:51 PM
10-30-2008 01:51 PM
Problem on poll(2) system call
I am seeing problem with ‘poll’ system call on “HP-UX 11i v3” but not on earlier versions.
count = poll(fds, MAXFDS, timeout);
fds[n].revents is set to POLLERR on a closed file descriptor but on other UNIX and earlier HP operating system fds[n].revents is set to POLLIN. Is this a bug on HP v3 system?
Aziz Ahmad
#include
..........
#define MAXFDS 1000
int main(int argc, char** argv)
{
int count;
bool terminate = false;
struct pollfd fds[MAXFDS];
// fds.fd[n] are either -1 or a valid file descriptor
// fds.events[n] = POLLIN for valif fds
// fds.revents[n] = 0
while(!terminate)
{
do
{
count = poll(fds, MAXFDS, 30);
} while ((count == -1) && (errno == EINTR));
if (count == -1) {
// clear bad file descriptor from poll array fds
// print error message
continue;
}
for int i=0; i {
// on v3 revents is set to POLLERR for a closed socket
// on v2 and earlier revents is set to POLLIN for a closed socket
if (fds[i].revents & POLLIN) // works fine on UNIX and HP except v3
// read fds[i].fd and do something
;
// recv on a closed socket returns 0 on hp v2 but 4 on v3
//
if (fds[i].revents & POLLIN | POLLERR) // POLLERR needed in v3 to work properly
// remove fd with POLLERR from fds array
// read fds[i].fd and do something
;
}
}
}
count = poll(fds, MAXFDS, timeout);
fds[n].revents is set to POLLERR on a closed file descriptor but on other UNIX and earlier HP operating system fds[n].revents is set to POLLIN. Is this a bug on HP v3 system?
Aziz Ahmad
#include
..........
#define MAXFDS 1000
int main(int argc, char** argv)
{
int count;
bool terminate = false;
struct pollfd fds[MAXFDS];
// fds.fd[n] are either -1 or a valid file descriptor
// fds.events[n] = POLLIN for valif fds
// fds.revents[n] = 0
while(!terminate)
{
do
{
count = poll(fds, MAXFDS, 30);
} while ((count == -1) && (errno == EINTR));
if (count == -1) {
// clear bad file descriptor from poll array fds
// print error message
continue;
}
for int i=0; i
// on v3 revents is set to POLLERR for a closed socket
// on v2 and earlier revents is set to POLLIN for a closed socket
if (fds[i].revents & POLLIN) // works fine on UNIX and HP except v3
// read fds[i].fd and do something
;
// recv on a closed socket returns 0 on hp v2 but 4 on v3
//
if (fds[i].revents & POLLIN | POLLERR) // POLLERR needed in v3 to work properly
// remove fd with POLLERR from fds array
// read fds[i].fd and do something
;
}
}
}
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2008 03:57 PM
10-30-2008 03:57 PM
Re: Problem on poll(2) system call
In the code you have provided is the commented-out stuff before while(!terminate) supposed to imply that fds has been initialized before the while loop?
Apart from wondering if folks using poll should always be checking for POLLERR anyway, regardless of past HP-UX behaviour, you might check for current patches to 11iv3. If you haven't already done so, checking the 11iv3 manpage for poll might be a good idea.
When you say closed socket, closed how exactly? And by that you mean a socket closed on the remote, or do you mean a local socket closed by another thread in the same appliction?
Is there any chance that data could have been in flight to this remote socket being closed and so triggering an RST?
Can you expand a bit on the comment "recv on a closed socket returns 0 on hp v2 but 4 on hpv3?
When/if you do go to the response center with this, they'll probably want a complete test case.
Apart from wondering if folks using poll should always be checking for POLLERR anyway, regardless of past HP-UX behaviour, you might check for current patches to 11iv3. If you haven't already done so, checking the 11iv3 manpage for poll might be a good idea.
When you say closed socket, closed how exactly? And by that you mean a socket closed on the remote, or do you mean a local socket closed by another thread in the same appliction?
Is there any chance that data could have been in flight to this remote socket being closed and so triggering an RST?
Can you expand a bit on the comment "recv on a closed socket returns 0 on hp v2 but 4 on hpv3?
When/if you do go to the response center with this, they'll probably want a complete test case.
there is no rest for the wicked yet the virtuous have no pillows
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
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP