libcamera/src
Julien Vuillaumier 5b7c83d8cc libcamera: process: Pass stderr and reserve stdin and stdout fds
When a child process is started from Process::start(), the file
descriptors inherited from the parent process are closed, except
the ones explicitly listed in the fds[] argument.

One issue is that the file descriptors for stdin, stdout and stderr
being closed, the subsequent file descriptors created by the child
process will reuse the values 0, 1 and 2 that are now available.
Thus, usage of printf(), assert() or alike may direct its output
to the new resource bound to one of these reused file descriptors.
The other issue is that the child process can no longer log on
the console because stderr has been closed.

To address the 2 issues, Process:start() is amended as below:
- Child process inherits from parent's stderr fd in order to share
the same logging descriptor
- Child process stdin, stdout and stderr fds are bound to /dev/null
if not inherited from parent. That is to prevent those descriptors
to be reused for any other resource, that could be corrupted by
the presence of printf(), assert() or alike.

Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-05-29 12:30:12 +01:00
..
android meson: Don't unnecessarily fallback to libyuv wrap 2024-11-26 19:05:17 +02:00
apps apps: cam: capture_script: Disallow arrays of strings 2025-05-22 13:16:07 +02:00
gstreamer utils: codegen: Make users depend on controls.py in meson 2025-05-22 13:16:07 +02:00
ipa treewide: Do not use *NameValueMap for known values 2025-05-27 09:42:46 +02:00
libcamera libcamera: process: Pass stderr and reserve stdin and stdout fds 2025-05-29 12:30:12 +01:00
py utils: codegen: Make users depend on controls.py in meson 2025-05-22 13:16:07 +02:00
v4l2 meson: Convert v4l2 into a feature option 2025-01-10 12:35:10 +01:00
meson.build libcamera: meson: Fix libyuv detection 2025-03-01 22:36:24 +00:00