]> Savannah Git Hosting - gnulib.git/commitdiff
supersede: Avoid a failure when writing to /dev/null in Solaris zones.
authorBruno Haible <bruno@clisp.org>
Mon, 12 Sep 2022 08:49:25 +0000 (10:49 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 12 Sep 2022 08:49:25 +0000 (10:49 +0200)
* lib/supersede.c (open_supersede): Treat EACCES (seen on Solaris 11.3)
like EINVAL (seen on Illumos).

ChangeLog
lib/supersede.c

index 5f70a809260e4838c3135b0853118cbad151c8c1..d812e73f553ddedeae40135d456c2f1720d92a1c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-09-12  Bruno Haible  <bruno@clisp.org>
+
+       supersede: Avoid a failure when writing to /dev/null in Solaris zones.
+       * lib/supersede.c (open_supersede): Treat EACCES (seen on Solaris 11.3)
+       like EINVAL (seen on Illumos).
+
 2022-09-11  Paul Eggert  <eggert@cs.ucla.edu>
 
        maint: avoid unportable ERE \}
index a72c4f40e83ae30f56984271d95df60eb60b3163..7fbd619fdebdee8cbdb1b478a96dfd81cfec74e8 100644 (file)
@@ -83,9 +83,12 @@ open_supersede (const char *filename, int flags, mode_t mode,
   /* Extra flags for existing devices.  */
   int extra_flags =
     #if defined __sun || (defined _WIN32 && !defined __CYGWIN__)
-    /* open ("/dev/null", O_TRUNC | O_WRONLY) fails with error EINVAL on Solaris
-       zones.  See <https://www.illumos.org/issues/13035>.
-       Likewise for open ("NUL", O_TRUNC | O_RDWR) on native Windows.
+    /* open ("/dev/null", O_TRUNC | O_WRONLY) fails on Solaris zones:
+         - with error EINVAL on Illumos, see
+           <https://www.illumos.org/issues/13035>,
+         - with error EACCES on Solaris 11.3.
+       Likewise, open ("NUL", O_TRUNC | O_RDWR) fails with error EINVAL on
+       native Windows.
        As a workaround, add the O_CREAT flag, although it ought not to be
        necessary.  */
     O_CREAT;
@@ -204,7 +207,7 @@ open_supersede (const char *filename, int flags, mode_t mode,
             }
           #if defined __sun || (defined _WIN32 && !defined __CYGWIN__)
           /* See the comment regarding extra_flags, above.  */
-          else if (errno == EINVAL)
+          else if (errno == EINVAL || errno == EACCES)
             {
               struct stat statbuf;