diff options
author | Dan Williams <dcbw@redhat.com> | 2009-06-25 16:45:49 -0400 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2009-06-25 16:45:49 -0400 |
commit | 112f2da19dbe8dcd8f32b998459298e7c1884c67 (patch) | |
tree | e82630a32c87b010c1e50c716a59fa222d00c136 | |
parent | bb50295e5efabf3f8dcbee1102bf3856343f04d9 (diff) |
serial-port: open port exclusively
-rw-r--r-- | src/mm-serial-port.c | 8 |
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)); |