From: Michael Tremer Date: Fri, 16 Dec 2022 10:25:26 +0000 (+0000) Subject: jail: communicate: Mark the stdin fd as closed to avoid later writes X-Git-Tag: 0.9.29~414 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5a70a96770f075ea1c9efe82f59ac2cb1370ab2;p=pakfire.git jail: communicate: Mark the stdin fd as closed to avoid later writes Signed-off-by: Michael Tremer --- 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; }