From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1598826-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 67D1E15815E
	for <garchives@archives.gentoo.org>; Fri,  9 Feb 2024 07:08:33 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 9A042E29CB;
	Fri,  9 Feb 2024 07:08:30 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 6B5A7E29CB
	for <gentoo-commits@lists.gentoo.org>; Fri,  9 Feb 2024 07:08:30 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 5834B343141
	for <gentoo-commits@lists.gentoo.org>; Fri,  9 Feb 2024 07:08:28 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 904A314BD
	for <gentoo-commits@lists.gentoo.org>; Fri,  9 Feb 2024 07:08:26 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1707462502.fba76a545f29fb8b529197c25c64700ef77413ae.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/
X-VCS-Repository: proj/portage
X-VCS-Files: lib/portage/gpkg.py
X-VCS-Directories: lib/portage/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: fba76a545f29fb8b529197c25c64700ef77413ae
X-VCS-Branch: master
Date: Fri,  9 Feb 2024 07:08:26 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: c2d29d1f-ef01-4d7e-8c23-47fd8e27285a
X-Archives-Hash: a6f25d9debcdf50d2a5cf44baf10c31a

commit:     fba76a545f29fb8b529197c25c64700ef77413ae
Author:     Matoro Mahri <matoro_gentoo <AT> matoro <DOT> tk>
AuthorDate: Wed Jan 31 20:25:40 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Feb  9 07:08:22 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=fba76a54

gpkg: on error, close stdin before killing external programs

Otherwise, this may trigger a BrokenPipeError.  Sensitive to buffer
fullness, this was observed on 64k page size system immediately after
triggering E2BIG error from kernel.

Signed-off-by: Matoro Mahri <matoro_gentoo <AT> matoro.tk>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/gpkg.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/portage/gpkg.py b/lib/portage/gpkg.py
index 031b3f87cb..05f1b5f2a6 100644
--- a/lib/portage/gpkg.py
+++ b/lib/portage/gpkg.py
@@ -149,9 +149,9 @@ class tar_stream_writer:
         kill external program if any error happened in python
         """
         if self.proc is not None:
-            self.killed = True
-            self.proc.kill()
             self.proc.stdin.close()
+            self.proc.kill()
+            self.killed = True
             self.close()
 
     def _cmd_read_thread(self):
@@ -347,9 +347,9 @@ class tar_stream_reader:
         kill external program if any error happened in python
         """
         if self.proc is not None:
-            self.killed = True
-            self.proc.kill()
             self.proc.stdin.close()
+            self.proc.kill()
+            self.killed = True
             self.close()
 
     def read(self, bufsize=-1):