You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An application might initialize a client, then fork/execve a child process, then exit. This would leave the serial port open and locked by the child process, which would prevent another process from initializing a client. This is because of the behavior documented in flock(2).
Locks created by flock() are preserved across an execve(2).
This can be mitigated. If the O_CLOEXEC option were added to the above open call, the child will close the serial port after execve, which will release the lock, per the following behavior also in flock(2).
Locks created by flock() are associated with an open file description (see open(2)). This means that duplicate file descriptors (created by, for example, fork(2) or dup(2)) refer to the same lock, and this lock may be modified or released using any of these file descriptors. Furthermore, the lock is released either by an explicit LOCK_UN operation on any of these duplicate file descriptors, or when all such file descriptors have been closed.
I discovered this behavior using Plex Media Player. It launches, then initializes a CEC client, then forks an unrelated pmphelper process. This process stays alive if the parent process exits, but does not use the CEC serial port. As a result, if the player launches again after the helper spawns, the helper will have the lock on the port and it will never be released.
The text was updated successfully, but these errors were encountered:
There is an issue when the library opens the serial port.
libcec/src/libcec/platform/posix/serialport.cpp
Line 134 in ba9b538
After the port is opened, libcec obtains an exclusive (single process only) lock on the device.
libcec/src/libcec/platform/posix/serialport.cpp
Line 143 in ba9b538
An application might initialize a client, then
fork
/execve
a child process, then exit. This would leave the serial port open and locked by the child process, which would prevent another process from initializing a client. This is because of the behavior documented inflock(2)
.This can be mitigated. If the
O_CLOEXEC
option were added to the aboveopen
call, the child will close the serial port afterexecve
, which will release the lock, per the following behavior also in flock(2).I discovered this behavior using Plex Media Player. It launches, then initializes a CEC client, then forks an unrelated
pmphelper
process. This process stays alive if the parent process exits, but does not use the CEC serial port. As a result, if the player launches again after the helper spawns, the helper will have the lock on the port and it will never be released.The text was updated successfully, but these errors were encountered: