nimbuscontrols / EIPScanner

Free implementation of EtherNet/IP in C++
https://eipscanner.readthedocs.io/en/latest/
MIT License
224 stars 90 forks source link

Prevent SIGPIPE signal when writing to closed socket #90

Closed JohannesKauffmann closed 1 year ago

JohannesKauffmann commented 1 year ago

By default, SIGPIPE will terminate the complete process. This is obviously not the ideal way to handle writing a closed socket. We already propagate EPIPE using the throw std::system_error. So, signal to the OS not to generate a signal.

The other option would be to install a signal handler for SIGPIPE, but that is not ideal inside a library.

manter-international commented 1 year ago

This only happens when the PLC closes the socket (for example when reprogrammed).
Fix tested, works. @JohannesKauffmann could you add some comments to the code?

JohannesKauffmann commented 1 year ago

Added some comments to explain what is being done.