From f5a70a96770f075ea1c9efe82f59ac2cb1370ab2 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 16 Dec 2022 10:25:26 +0000 Subject: [PATCH] jail: communicate: Mark the stdin fd as closed to avoid later writes Signed-off-by: Michael Tremer --- src/libpakfire/jail.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libpakfire/jail.c b/src/libpakfire/jail.c index 20785045e..391437fa1 100644 --- a/src/libpakfire/jail.c +++ b/src/libpakfire/jail.c @@ -543,6 +543,10 @@ static int pakfire_jail_stream_stdin(struct pakfire_jail* jail, return 0; } + // Skip if the writing pipe has already been closed + if (!ctx->pipes.stdin[1]) + return 0; + DEBUG(jail->pakfire, "Streaming standard input...\n"); // Calling the callback @@ -554,7 +558,13 @@ static int pakfire_jail_stream_stdin(struct pakfire_jail* jail, if (r == EOF) { DEBUG(jail->pakfire, "Closing standard input pipe\n"); + // Close the file-descriptor close(fd); + + // Reset the file-descriptor so it won't be closed again later + ctx->pipes.stdin[1] = 0; + + // Report success r = 0; } -- 2.47.3