[libcamera-devel] [PATCH] libcamera: v4l2_device: openat(2) with O_CLOEXEC to cleanup after exec(3)
Elias Naur
mail at eliasnaur.com
Sat Mar 11 20:05:25 CET 2023
It's generally a good idea to openat(2) with O_CLOEXEC, but this patch
also fixes a problem where the v4l2 devices would report -EBUSY after
an exec(3).
Signed-off-by: Elias Naur <mail at eliasnaur.com>
---
src/libcamera/v4l2_device.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git src/libcamera/v4l2_device.cpp src/libcamera/v4l2_device.cpp
index 57a88d96..ad9d1e37 100644
--- src/libcamera/v4l2_device.cpp
+++ src/libcamera/v4l2_device.cpp
@@ -86,7 +86,7 @@ int V4L2Device::open(unsigned int flags)
return -EBUSY;
}
- UniqueFD fd(syscall(SYS_openat, AT_FDCWD, deviceNode_.c_str(), flags));
+ UniqueFD fd(syscall(SYS_openat, AT_FDCWD, deviceNode_.c_str(), flags|O_CLOEXEC));
if (!fd.isValid()) {
int ret = -errno;
LOG(V4L2, Error) << "Failed to open V4L2 device '"
--
2.39.2
More information about the libcamera-devel
mailing list