diff --git a/sim_serial.c b/sim_serial.c index d9b5fdb2..9cdd78ae 100644 --- a/sim_serial.c +++ b/sim_serial.c @@ -1324,10 +1324,14 @@ int written; written = write (port, (void *) buffer, (size_t) count); /* write the buffer to the serial port */ if (written == -1) { - if (errno != EAGAIN) /* unexpected error? */ - sim_error_serial ("write", errno); /* report it */ - else + if (errno == EWOULDBLOCK) written = 0; /* not an error, but nothing written */ +#if defined(EAGAIN) + else if (errno == EAGAIN) + written = 0; /* not an error, but nothing written */ +#endif + else /* unexpected error? */ + sim_error_serial ("write", errno); /* report it */ } return (int32) written; /* return number of characters written */