Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » SIGPIPE problem
Re: SIGPIPE problem [message #57154 is a reply to message #57152] Tue, 01 June 2021 13:15 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Well, the SIGPIPE issue is a relic network/socket programmers have to deal with, dating back to the implementation of TCP sockets in unix in early 80s.

AFAIK, there is no perfect solution. While the posix manual seems to define MSG_NOSIGNAL from some point on, it is not adopted by every camp yet.

Another workaround seems to be this, which I didn't know either:


Quote:

The most general solution, for when you are not in full control of the program's signal handling and want to write data to an actual pipe or use write(2) on a socket, is to first mask the signal for the current thread with pthread_sigmask(3), write the data, drain any pending signal with sigtimedwait(2) and a zero timeout, and then finally unmask SIGPIPE. This technique is described in more detail here. Note that some systems such as OpenBSD do not have sigtimedwait(2) in which case you need to use sigpending(2) to check for pending signals and then call the blocking sigwait(2).


Read the full blog, here:

https://www.doof.me.uk/2020/09/23/sigpipe-and-how-to-ignore- it/

Workaround (explained):
https://web.archive.org/web/20200126153413/http://www.microh owto.info:80/howto/ignore_sigpipe_without_affecting_other_th reads_in_a_process.html

Best regards,
Oblivion


[Updated on: Tue, 01 June 2021 13:23]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Small optimization
Next Topic: MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg
Goto Forum:
  


Current Time: Thu May 09 14:34:35 CEST 2024

Total time taken to generate the page: 0.01576 seconds