Browse Source

HAL_SITL: Attempting to avoid SIGPIPE on all platforms

master
John Boiles 12 years ago committed by Andrew Tridgell
parent
commit
d8cdb57efa
  1. 2
      libraries/AP_HAL_AVR_SITL/SITL_State.cpp
  2. 12
      libraries/AP_HAL_AVR_SITL/UARTDriver.cpp

2
libraries/AP_HAL_AVR_SITL/SITL_State.cpp

@ -97,6 +97,8 @@ void SITL_State::_parse_command_line(int argc, char * const argv[]) @@ -97,6 +97,8 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
int opt;
signal(SIGFPE, _sig_fpe);
// No-op SIGPIPE handler
signal(SIGPIPE, SIG_IGN);
setvbuf(stdout, (char *)0, _IONBF, 0);
setvbuf(stderr, (char *)0, _IONBF, 0);

12
libraries/AP_HAL_AVR_SITL/UARTDriver.cpp

@ -40,14 +40,6 @@ @@ -40,14 +40,6 @@
using namespace AVR_SITL;
// On OSX, MSG_NOSIGNAL doesn't exist. The equivalent is to set SO_NOSIGPIPE
// in setsockopt for the socket. However, if we just skip that, and don't use
// MSG_NOSIGNAL, everything seems to work fine and SIGPIPE doesn't seem to be
// generated.
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
bool SITLUARTDriver::_console;
/* UARTDriver method implementations */
@ -139,7 +131,7 @@ int16_t SITLUARTDriver::read(void) @@ -139,7 +131,7 @@ int16_t SITLUARTDriver::read(void)
return ::read(0, &c, 1);
}
int n = recv(_fd, &c, 1, MSG_DONTWAIT | MSG_NOSIGNAL);
int n = recv(_fd, &c, 1, MSG_DONTWAIT);
if (n <= 0) {
// the socket has reached EOF
close(_fd);
@ -160,7 +152,7 @@ void SITLUARTDriver::flush(void) @@ -160,7 +152,7 @@ void SITLUARTDriver::flush(void)
size_t SITLUARTDriver::write(uint8_t c)
{
int flags = MSG_NOSIGNAL;
int flags = 0;
_check_connection();
if (!_connected) {
return 0;

Loading…
Cancel
Save