X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=serialport.c;h=c233b28564c799b66cd3e903cd92dd45a9ea6ded;hb=d9cc984fe7acc487d39366a98f1d3759f6129361;hp=2c1b68217eaf0747d93761fc5af61a6accaa45c4;hpb=bd0fb6094f3b3cf7368bb17b09e30dd3408f9eae;p=libserialport.git diff --git a/serialport.c b/serialport.c index 2c1b682..c233b28 100644 --- a/serialport.c +++ b/serialport.c @@ -563,7 +563,7 @@ SP_API enum sp_return sp_open(struct sp_port *port, enum sp_mode flags) RETURN_CODEVAL(ret); } #else - int flags_local = O_NONBLOCK | O_NOCTTY; + int flags_local = O_NONBLOCK | O_NOCTTY | O_CLOEXEC; /* Map 'flags' to the OS-specific settings. */ if ((flags & SP_MODE_READ_WRITE) == SP_MODE_READ_WRITE) @@ -742,7 +742,9 @@ SP_API enum sp_return sp_drain(struct sp_port *port) #else int result; while (1) { -#ifdef __ANDROID__ +#if defined(__ANDROID__) && (__ANDROID_API__ < 21) + /* Android only has tcdrain from platform 21 onwards. + * On previous API versions, use the ioctl directly. */ int arg = 1; result = ioctl(port->fd, TCSBRK, &arg); #else