From 112f2da19dbe8dcd8f32b998459298e7c1884c67 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 25 Jun 2009 16:45:49 -0400 Subject: [PATCH] serial-port: open port exclusively --- src/mm-serial-port.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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));