aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mm-serial-port.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
index 357fc947..564a8ace 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-serial-port.c
@@ -671,6 +671,14 @@ mm_serial_port_open (MMSerialPort *self, GError **error)
return FALSE;
}
+ if (ioctl (priv->fd, TIOCEXCL) < 0) {
+ g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_OPEN_FAILED,
+ "Could not lock serial device %s: %s", device, strerror (errno));
+ close (priv->fd);
+ priv->fd = -1;
+ return FALSE;
+ }
+
if (ioctl (priv->fd, TCGETA, &priv->old_t) < 0) {
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_OPEN_FAILED,
"Could not open serial device %s: %s", device, strerror (errno));