From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id BF3541F5AE for ; Sat, 27 Jun 2020 22:04:30 +0000 (UTC) Received: from localhost ([::1]:50672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpIw1-00037w-TB for normalperson@yhbt.net; Sat, 27 Jun 2020 18:04:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpIvE-00021D-VN for bug-gnulib@gnu.org; Sat, 27 Jun 2020 18:03:41 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.219]:36418) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpIvA-0005tJ-Sy for bug-gnulib@gnu.org; Sat, 27 Jun 2020 18:03:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1593295414; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=5FdyYcY7G7QFsoY80rtPw90zyYG5cIprILG7X44C3vY=; b=HFJJ3SCNLXZ1m69nxNN9v7N7+K+plHZNYfgunyM/6kQo2Vn52pxYMlZ4yhey5K+z94 FNPJ3sA1dJe9YKKknMMihS8I4tO+XYiuyJCQ2GMLWkGEfPZu88XMcWC9uVitSgY/Pjlg 7g6VDriXY9I2SXgff49atBbAlUMUowdjo1ih5+uvb83EUu48eLUbEhav7OfyBOH5qQU2 AHT1DmfERg0fX/921OE+qZ5f0UDFczpfAfKd3/9Ff+iSycS0QNlAImEAQjyavg8rRQbQ VQsiKggf2Gy83A6FLNT0qLu3BnpyfltEQ/sdkjXg5SJxBMIStavWc22wKpi1wMU2q6EZ +PrQ== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.10.5 DYNA|AUTH) with ESMTPSA id R03d1aw5RM3XMst (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sun, 28 Jun 2020 00:03:33 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: fatal-signal: Don't force deletion of temporary files on native Windows Date: Sun, 28 Jun 2020 00:03:32 +0200 Message-ID: <2813592.yb4WB7jtDI@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-179-generic; KDE/5.18.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.219; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/27 18:03:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" There are temporary files that need to be accessible by their name, after they have been completed. And there are temporary files that don't need that. I don't remember why fatal-signal supports only the second category. Both need to be supported. 2020-06-27 Bruno Haible fatal-signal: Don't force deletion of temporary files on native Windows. * lib/clean-temp.h (open_temp, fopen_temp): Add delete_on_close argument. * lib/clean-temp.c (open_temp, fopen_temp): Likewise. * NEWS: Mention the change. * lib/javacomp.c (write_temp_file): Update. diff --git a/NEWS b/NEWS index 5684494..668f2d6 100644 --- a/NEWS +++ b/NEWS @@ -58,6 +58,10 @@ User visible incompatible changes Date Modules Changes +2020-06-27 clean-temp The functions open_temp, fopen_temp now take a + 'bool delete_on_close' argument. If in doubt, pass + false. + 2020-06-27 tempname The link requirements of these modules are changed mkdtemp from empty to $(LIB_GETRANDOM). mkstemp diff --git a/lib/clean-temp.c b/lib/clean-temp.c index c57d658..b9badac 100644 --- a/lib/clean-temp.c +++ b/lib/clean-temp.c @@ -630,7 +630,7 @@ unregister_fd (int fd) /* Open a temporary file in a temporary directory. Registers the resulting file descriptor to be closed. */ int -open_temp (const char *file_name, int flags, mode_t mode) +open_temp (const char *file_name, int flags, mode_t mode, bool delete_on_close) { int fd; int saved_errno; @@ -640,7 +640,7 @@ open_temp (const char *file_name, int flags, mode_t mode) #if defined _WIN32 && ! defined __CYGWIN__ /* Use _O_TEMPORARY when possible, to increase the chances that the temporary file is removed when the process crashes. */ - if (supports_delete_on_close ()) + if (delete_on_close && supports_delete_on_close ()) fd = open (file_name, flags | _O_TEMPORARY, mode); else #endif @@ -656,7 +656,7 @@ open_temp (const char *file_name, int flags, mode_t mode) /* Open a temporary file in a temporary directory. Registers the resulting file descriptor to be closed. */ FILE * -fopen_temp (const char *file_name, const char *mode) +fopen_temp (const char *file_name, const char *mode, bool delete_on_close) { FILE *fp; int saved_errno; @@ -666,7 +666,7 @@ fopen_temp (const char *file_name, const char *mode) #if defined _WIN32 && ! defined __CYGWIN__ /* Use _O_TEMPORARY when possible, to increase the chances that the temporary file is removed when the process crashes. */ - if (supports_delete_on_close ()) + if (delete_on_close && supports_delete_on_close ()) { size_t mode_len = strlen (mode); char *augmented_mode = (char *) xmalloca (mode_len + 2); diff --git a/lib/clean-temp.h b/lib/clean-temp.h index 620bd08..5b66328 100644 --- a/lib/clean-temp.h +++ b/lib/clean-temp.h @@ -117,9 +117,13 @@ extern int cleanup_temp_dir_contents (struct temp_dir *dir); extern int cleanup_temp_dir (struct temp_dir *dir); /* Open a temporary file in a temporary directory. - Registers the resulting file descriptor to be closed. */ -extern int open_temp (const char *file_name, int flags, mode_t mode); -extern FILE * fopen_temp (const char *file_name, const char *mode); + Registers the resulting file descriptor to be closed. + DELETE_ON_CLOSE indicates whether the file can be deleted when the resulting + file descriptor or stream is closed. */ +extern int open_temp (const char *file_name, int flags, mode_t mode, + bool delete_on_close); +extern FILE * fopen_temp (const char *file_name, const char *mode, + bool delete_on_close); /* Close a temporary file in a temporary directory. Unregisters the previously registered file descriptor. */ diff --git a/lib/javacomp.c b/lib/javacomp.c index 4717a5f..63efc2d 100644 --- a/lib/javacomp.c +++ b/lib/javacomp.c @@ -573,7 +573,7 @@ write_temp_file (struct temp_dir *tmpdir, const char *file_name, FILE *fp; register_temp_file (tmpdir, file_name); - fp = fopen_temp (file_name, "we"); + fp = fopen_temp (file_name, "we", false); if (fp == NULL) { error (0, errno, _("failed to create \"%s\""), file_name);