- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to handle SIGPIPE when writing to broken s...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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-31-2011 06:01 PM
10-31-2011 06:01 PM
How to handle SIGPIPE when writing to broken socket
I am writing something which attempts to send a message over a TCP connection. I have come across an issue where the connection might break. When this occurs, HPUX throws a sigpipe and sets errno appropriately.
I am having an issue with the signal that is generated. If I want to create a library which handles this, that means that I need to add a signal handler for SIGPIPE within a shared object. I have also attempted to block signals within my own thread by pthread_sigmask. However, this requires my library, and consequentially, executables consuming my API to link with the pthread library.
Is there a more elegant way to do this? Or is there no way around it?
- Tags:
- SIGPIPE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2011 12:14 AM
11-01-2011 12:14 AM
Re: How to handle SIGPIPE when writing to broken socket
Any reason you don't block or ignore all SIGPIPEs?
>I have also attempted to block signals within my own thread by pthread_sigmask. However, this requires my library, and consequentially, executables consuming my API to link with the pthread library.
Why do you think you have threads? If you have threads, then the application already is linked with libpthread.
There may already be stubs in libc for pthread_sigmask?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2011 07:26 AM
11-01-2011 07:26 AM
Re: How to handle SIGPIPE when writing to broken socket
The only reason that I can think is that the linking application might want to do some action when it receives a SIGPIPE. I do not want my handlers to potentially catch their signals. I also do not want to go the other way and have them catch my signals.
I currently use pthread_sigmask in the event that the linking application might be multithreaded (already link with pthread). But I would like to avoid having pthread be a requirement for linking with my library.
I did notice that pthread_sigmask does have stubs in libc, however, they are stubs, and do not seem to block any threads (or it could have been a mistake on my part for not getting the desired behavior).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2011 07:57 PM
11-01-2011 07:57 PM
Re: How to handle SIGPIPE when writing to broken socket
>I do not want my handlers to potentially catch their signals. I also do not want to go the other way and have them catch my signals.
Well, unless you are in a separate thread, there is no good way to know which is yours vs theirs unless you continually set and reset them.
>I would like to avoid having pthread be a requirement for linking with my library.
With the stubs, you don't need to care, too much.
>do not seem to block any threads
That's correct, pthread_sigmask returns 0. You need to have a plan B that detects if you aren't in a thread.