From 2c4db997a9d87a51dea7d431f9e6b51573075fb5 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 5 Sep 2024 22:43:42 +0200 Subject: [PATCH] linux: ignore EPIPE for hooks ignore EPIPE when writing to the hook stdin, as the hook process could already have been terminated. Closes: https://github.com/containers/crun/issues/1551 Signed-off-by: Giuseppe Scrivano --- src/libcrun/utils.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libcrun/utils.c b/src/libcrun/utils.c index 717fee148..4dbc7f68e 100644 --- a/src/libcrun/utils.c +++ b/src/libcrun/utils.c @@ -1671,8 +1671,13 @@ run_process_with_stdin_timeout_envp (char *path, char **args, const char *cwd, i ret = TEMP_FAILURE_RETRY (write (pipe_w, stdin, stdin_len)); if (UNLIKELY (ret < 0)) { - ret = crun_make_error (err, errno, "writing to pipe"); - goto restore_sig_mask_and_exit; + /* Ignore EPIPE as the container process could have already + been terminated. */ + if (errno != EPIPE) + { + ret = crun_make_error (err, errno, "writing to pipe"); + goto restore_sig_mask_and_exit; + } } close_and_reset (&pipe_w);