Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not ignore errors on exclusive acquisition/release of the port #63

Open
wants to merge 1 commit into
base: v1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions serial_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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{}
Expand Down