From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 97E863858D33 for ; Tue, 28 Feb 2023 10:12:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97E863858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677579138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w4D7mvYamidCpdVNxsBMlKhBVJbR32wdxixWU62+y7c=; b=FQVlMGwp4hElBZgEU/7aOsotN3+bwOWKkRCzhELwjyZ+g+qiyXMa/2yHufxp8hMT4Zb+1d FfxLYp+Ev6xZurIDfvDQRaHpwQZ3Ks3uVkT+PC8OplzUAmh9qxdMMM2KKnpHQuk+Ywj8wI zp9XsHIFQsXlqlCCnGAyqG5FlhWRCFg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-271-Q7qmHzkJPIWkHR8hQSEQIQ-1; Tue, 28 Feb 2023 05:12:16 -0500 X-MC-Unique: Q7qmHzkJPIWkHR8hQSEQIQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F2651C0896D; Tue, 28 Feb 2023 10:12:16 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C78FF492B13; Tue, 28 Feb 2023 10:12:15 +0000 (UTC) From: Florian Weimer To: Gioele Barabucci Cc: Gioele Barabucci via Systemtap Subject: Re: [PATCH] dtrace: Use deterministic temp file creation for all temp files References: <6bfff40c-2c4b-c119-116d-7834310299d7@svario.it> <87fsarm7m5.fsf@oldenburg.str.redhat.com> <3de411c4-8cbd-667b-a64e-aeeac297ea94@svario.it> <87356rm4wx.fsf@oldenburg.str.redhat.com> <9af13f7f-6633-6552-c572-92a45c80c743@svario.it> <87edqbko5a.fsf@oldenburg.str.redhat.com> <9a0b9a4d-c0cb-88eb-499a-e6682b6acdbb@svario.it> Date: Tue, 28 Feb 2023 11:12:13 +0100 In-Reply-To: <9a0b9a4d-c0cb-88eb-499a-e6682b6acdbb@svario.it> (Gioele Barabucci's message of "Tue, 28 Feb 2023 04:46:55 +0100") Message-ID: <87bklenloi.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Gioele Barabucci: > On 27/02/23 18:34, Florian Weimer wrote: >> * Gioele Barabucci: >>=20 >>> @@ -380,6 +373,7 @@ def main(): >>> usage() >>> return 1 >>> + TEMP_DIR =3D mkdtemp() >>> if s_filename !=3D "" and use_cpp: >>> (ignore, fname) =3D mktemp_determ(["use_cpp", s_filename], su= ffix=3D".d") >>> cpp =3D os.environ.get("CPP", "cpp") >>> @@ -458,6 +452,9 @@ def main(): >>> else: >>> print("cpp: " + s_filename) >>> + if not keep_temps: >>> + os.rmdir(TEMP_DIR) >> This should probably use try:/finally: > > You mean wrapping the whole function in a try:/finally: or just the > `os.rmdir`? The whole thing. > The former implicates a quite invasive refactoring of the code > (patch-wise a complete rewrite); the latter seems overkill given that > the other `os.remove` calls are not checked and the only possibilities > are either silencing the error (pass) or exit with an error code > (similar to what the exception would do anyway). Okay, if the code isn't ready for this =E2=80=A6 >> or a context manager with tempfile.TemporaryDirectory. > > Wouldn't that greatly complicate the handling of `-k`/`keep_temps`? a > context manager with `TemporaryDirectory` will unconditionally remove > the directory and all its content on completion. Looks like it, TemporyFile has a no-delete option, but TemporaryDirectory does not. Thanks, Florian