From 721960a449e26ef78114909b820e712ebf71a751 Mon Sep 17 00:00:00 2001 From: gm42 Date: Tue, 23 Jul 2019 14:05:22 +0200 Subject: [PATCH] Do not ignore errors on exclusive acquisition of the port --- serial_unix.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/serial_unix.go b/serial_unix.go index 1cf690f..9576f35 100644 --- a/serial_unix.go +++ b/serial_unix.go @@ -30,7 +30,7 @@ type unixPort struct { func (port *unixPort) Close() error { // Close port - port.releaseExclusiveAccess() + _ = port.releaseExclusiveAccess() if err := unix.Close(port.handle); err != nil { return err } @@ -182,7 +182,11 @@ func nativeOpen(portName string, mode *Mode) (*unixPort, error) { unix.SetNonblock(h, false) - port.acquireExclusiveAccess() + err = port.acquireExclusiveAccess() + if err != nil { + port.Close() + return nil, err + } // This pipe is used as a signal to cancel blocking Read pipe := &unixutils.Pipe{}