bug-gnulib
[Top][All Lists]
Advanced

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

Re: stdio-safer and tmpfile


From: Eric Blake
Subject: Re: stdio-safer and tmpfile
Date: Sun, 23 Jul 2006 07:23:15 -0600
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

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

According to Eric Blake on 7/21/2006 9:51 AM:
> 
> Okay to install?
> 
> ChangeLog:
> 2006-07-21  Eric Blake  <address@hidden>
> 
>       * modules/stdio-safer (Files): Add tmpfile-safer.c.
>       (Depends-on): Add binary-io.
> 
>       * stdio-safer.m4 (gl_STDIO_SAFER): Add tmpfile-safer.c.
> 
>       * tmpfile-safer.c: New file.
>       * stdio-safer.h (tmpfile_safer): Add prototype.
>       * stdio--.h (tmpfile): Make safer.

Checked in, with additional documentation in tmpfile_safer that tmpfile is
incompatible with close_stdout.  However, using stdio-safer on mingw
(which lacks pipe, even though it has popen) evokes a compiler warning due
to the unconditional use of pipe within unistd-safer.  Is it okay to add
this followon that neutralizes pipe_safer on platforms lacking pipe?  For
now, this approach is easier than trying to implement pipe using either
Bruno's pipe module or trying to figure out if the Windows API can create
pipes.

m4/ChangeLog:
2006-07-23  Eric Blake  <address@hidden>

        * unistd-safer.m4 (gl_UNISTD_SAFER): Check for missing pipe.

2006-07-23  Eric Blake  <address@hidden>

        * pipe-safer.c (pipe_safer) [!HAVE_FUNC_PIPE]: Provide fallback to
        avoid compilation warning on mingw.

- --
Life is short - so eat dessert first!

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

iD8DBQFEw3hC84KuGfSFAYARAl5WAKCPEfm51Kut3hdELH/IR29LB2hbNwCcDzOC
e4LjPkaSlwU7ohKLQyZcnBU=
=CNzJ
-----END PGP SIGNATURE-----
Index: lib/pipe-safer.c
===================================================================
RCS file: /sources/gnulib/gnulib/lib/pipe-safer.c,v
retrieving revision 1.2
diff -u -p -r1.2 pipe-safer.c
--- lib/pipe-safer.c    19 Sep 2005 17:28:14 -0000      1.2
+++ lib/pipe-safer.c    23 Jul 2006 13:20:58 -0000
@@ -1,5 +1,5 @@
 /* Invoke pipe, but avoid some glitches.
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -24,13 +24,16 @@
 #include "unistd-safer.h"
 
 #include <unistd.h>
+#include <errno.h>
 
 /* Like pipe, but ensure that neither of the file descriptors is
-   STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO.  */
+   STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO.  Fail with ENOSYS on
+   platforms that lack pipe.  */
 
 int
 pipe_safer (int fd[2])
 {
+#if HAVE_FUNC_PIPE
   int fail = pipe (fd);
   if (fail)
     return fail;
@@ -47,4 +50,8 @@ pipe_safer (int fd[2])
   }
 
   return 0;
+#else /* ! HAVE_FUNC_PIPE */
+  errno = ENOSYS;
+  return -1;
+#endif
 }
Index: m4/unistd-safer.m4
===================================================================
RCS file: /sources/gnulib/gnulib/m4/unistd-safer.m4,v
retrieving revision 1.7
diff -u -p -r1.7 unistd-safer.m4
--- m4/unistd-safer.m4  23 Sep 2005 04:15:13 -0000      1.7
+++ m4/unistd-safer.m4  23 Jul 2006 13:20:58 -0000
@@ -1,11 +1,12 @@
-#serial 7
-dnl Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+#serial 8
+dnl Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_UNISTD_SAFER],
 [
+  AC_CHECK_FUNCS_ONCE([pipe])
   AC_LIBSOURCES([dup-safer.c, fd-safer.c, pipe-safer.c, unistd-safer.h, 
unistd--.h])
   AC_LIBOBJ([dup-safer])
   AC_LIBOBJ([fd-safer])

reply via email to

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