m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Frozen state generation fails with returncode 0


From: Eric Blake
Subject: Re: Frozen state generation fails with returncode 0
Date: Wed, 21 May 2008 21:51:21 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[adding m4-patches]

According to Jean-Charles Longuet on 5/21/2008 2:10 PM:
|
| When m4 fails to open() the frozen state file, it complains
| but the process exit code is still 0. However, the same function
| may trigger failures leading to a non-zero process exit code,
| for example when the close() of the frozen state file fails.

Thanks for the report.  Which version of m4 was this against?  I'm
guessing this was against a release tarball, rather than the current git
repository, since this area of code has changed in the meantime?

|
| Wouldn't it be consistent to also exit on open() failures,
| with this one-line patch or equivalent ?

abort() is too strong - users should not get a core dump merely because
they requested a file that can't be opened.  So I'll be applying this instead:

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkg07bkACgkQ84KuGfSFAYDg3ACgkAWSHOmo/6ZEJN0UfFFjvpQO
rEsAoNS6qOHX6jvJYYsKNaBRToRPVhmB
=UMHy
-----END PGP SIGNATURE-----
>From ebc0275ff983bf9016ffb4f19eb5a4c678691b54 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 21 May 2008 21:49:54 -0600
Subject: [PATCH] Don't allow failure to freeze give exit status of 0.

* src/freeze.c (produce_frozen_state): Die rather than warn.
* doc/m4.texinfo (Using frozen files): Test it.
* THANKS: Update.
Reported by Jean-Charles Longuet.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog      |    8 ++++++++
 THANKS         |    1 +
 doc/m4.texinfo |   10 ++++++++++
 src/freeze.c   |    5 +----
 4 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2abc489..9307dda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-22  Eric Blake  <address@hidden>
+
+       Don't allow failure to freeze give exit status of 0.
+       * src/freeze.c (produce_frozen_state): Die rather than warn.
+       * doc/m4.texinfo (Using frozen files): Test it.
+       * THANKS: Update.
+       Reported by Jean-Charles Longuet.
+
 2008-05-09  Eric Blake  <address@hidden>
 
        Improve error message when frozen file is invalid.
diff --git a/THANKS b/THANKS
index 19c1d92..1fa9ba5 100644
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 3131e9a..380bc34 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -6993,6 +6993,16 @@ ifdef(`__unix__', ,
 ')m4exit(`77')')dnl
 traceon(`undefined')dnl
 @end example
+
address@hidden Make sure freezing is successful.
+
address@hidden options -F /none/such
address@hidden status: 1
address@hidden
+$ @kbd{m4 -F /none/such}
+^D
address@hidden: cannot open /none/such: No such file or directory
address@hidden example
 @end ignore
 
 When an @code{m4} run is to be frozen, the automatic undiversion
diff --git a/src/freeze.c b/src/freeze.c
index 15f06fe..2734efa 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -58,10 +58,7 @@ produce_frozen_state (const char *name)
 
   file = fopen (name, O_BINARY ? "wb" : "w");
   if (!file)
-    {
-      m4_error (0, errno, NULL, _("cannot open %s"), name);
-      return;
-    }
+    m4_error (EXIT_FAILURE, errno, NULL, _("cannot open %s"), name);
 
   /* Write a recognizable header.  */
 
-- 
1.5.5.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]