core/execute: introduce exec_input_is_inheritable() helper

This commit is contained in:
Mike Yuan
2025-12-17 23:23:22 +00:00
committed by Luca Boccassi
parent b34aee0440
commit e04382384d
2 changed files with 13 additions and 11 deletions
+10
View File
@@ -480,6 +480,16 @@ static inline bool exec_context_has_tty(const ExecContext *context) {
context->std_error == EXEC_OUTPUT_TTY;
}
static inline bool exec_input_is_inheritable(ExecInput i) {
/* We assume these listed inputs refer to bidirectional streams, and hence duplicating them from
* stdin to stdout/stderr makes sense and hence allowing EXEC_OUTPUT_INHERIT makes sense, too.
* Outputs such as regular files or sealed data memfds otoh don't really make sense to be
* duplicated for both input and output at the same time (since they then would cause a feedback
* loop). */
return exec_input_is_terminal(i) || IN_SET(i, EXEC_INPUT_SOCKET, EXEC_INPUT_NAMED_FD);
}
int exec_spawn(
Unit *unit,
ExecCommand *command,