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

buses/uart: Use 'lockf()' for serial locking #637

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thg2k
Copy link

@thg2k thg2k commented Apr 13, 2021

Using this standard Linux mechanism to lock serial ports has the advantage that if the process is killed the lock is automatically released.

Before a lock was simulated using the custom termios 'c_iflag' value 0x80000000, which has the disadvantage, other than being non-standard, that if the process is killed before closing the serial port, it would appear as locked and require manual cleanup of the flag.

Using this standard Linux mechanism to lock serial ports has the advantage that if the process is killed the lock is automatically released.

Before a lock was simulated using the custom termios 'c_iflag' value 0x80000000, which has the disadvantage, other than being non-standard, that if the process is killed before closing the serial port, it would appear as locked and require manual cleanup of the flag.

Signed-off-by: Giovanni Giacobbi <[email protected]>
Copy link
Contributor

@smortex smortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have a compatible lockf(3) on FreeBSD:

STANDARDS
     The lockf() function conforms to X/Open Portability Guide Issue 4,
     Version 2 (“XPG4.2”).

@neomilium
Copy link
Member

Does it work under Windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants