unistd: guarantee STDIN_FILENO here, for OS/2 EMX
authorEric Blake <ebb9@byu.net>
Mon, 19 Jan 2009 16:27:47 +0000 (09:27 -0700)
committerEric Blake <ebb9@byu.net>
Mon, 19 Jan 2009 16:27:47 +0000 (09:27 -0700)
* lib/unistd.in.h (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO):
Guarantee a definition.
* doc/posix-headers/unistd.texi (unistd.h): Document the bug.
* modules/unistd-safer (Depends-on): Add dependency on unistd.
* lib/c-stack.c (STDERR_FILENO): Rely on <unistd.h>.
* lib/dup-safer.c (STDERR_FILENO): Likewise.
* lib/execute.c (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO):
Likewise.
* lib/fd-safer.c (STDIN_FILENO, STDERR_FILENO): Likewise.
* lib/fopen-safer.c (STDERR_FILENO): Likewise.
* lib/pipe.c (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO):
Likewise.
* lib/tmpfile-safer.c (STDERR_FILENO): Likewise.
* tests/test-posix_spawn1.c (STDIN_FILENO, STDOUT_FILENO)
(STDERR_FILENO): Likewise.
* tests/test-posix_spawn2.c (STDIN_FILENO, STDOUT_FILENO)
(STDERR_FILENO): Likewise.
* tests/test-posix_spawn3.c (STDIN_FILENO, STDOUT_FILENO)
(STDERR_FILENO): Likewise.
Reported by Elbert Pol.

Signed-off-by: Eric Blake <ebb9@byu.net>
14 files changed:
ChangeLog
doc/posix-headers/unistd.texi
lib/c-stack.c
lib/dup-safer.c
lib/execute.c
lib/fd-safer.c
lib/fopen-safer.c
lib/pipe.c
lib/tmpfile-safer.c
lib/unistd.in.h
modules/unistd-safer
tests/test-posix_spawn1.c
tests/test-posix_spawn2.c
tests/test-posix_spawn3.c

index 12adb30..22ad726 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2009-01-19  Eric Blake  <ebb9@byu.net>
 
+       unistd: guarantee STDIN_FILENO here, for OS/2 EMX
+       * lib/unistd.in.h (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO):
+       Guarantee a definition.
+       * doc/posix-headers/unistd.texi (unistd.h): Document the bug.
+       * modules/unistd-safer (Depends-on): Add dependency on unistd.
+       * lib/c-stack.c (STDERR_FILENO): Rely on <unistd.h>.
+       * lib/dup-safer.c (STDERR_FILENO): Likewise.
+       * lib/execute.c (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO):
+       Likewise.
+       * lib/fd-safer.c (STDIN_FILENO, STDERR_FILENO): Likewise.
+       * lib/fopen-safer.c (STDERR_FILENO): Likewise.
+       * lib/pipe.c (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO):
+       Likewise.
+       * lib/tmpfile-safer.c (STDERR_FILENO): Likewise.
+       * tests/test-posix_spawn1.c (STDIN_FILENO, STDOUT_FILENO)
+       (STDERR_FILENO): Likewise.
+       * tests/test-posix_spawn2.c (STDIN_FILENO, STDOUT_FILENO)
+       (STDERR_FILENO): Likewise.
+       * tests/test-posix_spawn3.c (STDIN_FILENO, STDOUT_FILENO)
+       (STDERR_FILENO): Likewise.
+       Reported by Elbert Pol.
+
+2009-01-19  Eric Blake  <ebb9@byu.net>
+
        doc: mention more functions added in cygwin 1.7.0
        * doc/posix-functions/abort.texi (abort): Update wording related
        to cygwin.
index b4336a6..855eefb 100644 (file)
@@ -10,7 +10,11 @@ Portability problems fixed by Gnulib:
 @item
 This header file is missing on some platforms: msvc.
 @item
-The SEEK_* macros are not defined in this file on some platforms: mingw.
+The SEEK_* macros are not defined in this file on some platforms:
+mingw.
+@item
+The *_FILENO macros are not defined in this file on some platforms:
+OS/2 EMX, mingw.
 @item
 The @code{_exit} function is not declared in this file on some platforms:
 mingw.
index 023f847..e5e3ab6 100644 (file)
@@ -1,6 +1,7 @@
 /* Stack overflow handling.
 
-   Copyright (C) 2002, 2004, 2006, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006, 2008, 2009 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
@@ -67,9 +68,6 @@ typedef struct sigaltstack stack_t;
 #endif
 
 #include <unistd.h>
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
 
 #if HAVE_LIBSIGSEGV
 # include <sigsegv.h>
index a690851..7d9b2be 100644 (file)
@@ -1,6 +1,7 @@
 /* Invoke dup, but avoid some glitches.
 
-   Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2004, 2005, 2006, 2009 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,9 +25,6 @@
 #include <fcntl.h>
 
 #include <unistd.h>
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
 
 /* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or
    STDERR_FILENO.  */
index 231f467..71da46f 100644 (file)
@@ -1,5 +1,5 @@
 /* Creation of autonomous subprocesses.
-   Copyright (C) 2001-2004, 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2001-2004, 2006-2009 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
 
 #endif
 
-#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-#endif
-#ifndef STDOUT_FILENO
-# define STDOUT_FILENO 1
-#endif
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
-
 /* The results of open() in this file are not used with fchdir,
    therefore save some unnecessary work in fchdir.c.  */
 #undef open
index df38c8f..fb99001 100644 (file)
@@ -1,6 +1,6 @@
 /* Return a safer copy of a file descriptor.
 
-   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2009 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
 #include <errno.h>
 
 #include <unistd.h>
-#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-#endif
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
 
 /* Return FD, unless FD would be a copy of standard input, output, or
    error; in that case, return a duplicate of FD, closing FD.  On
index 55991a2..9c79922 100644 (file)
@@ -1,6 +1,7 @@
 /* Invoke fopen, but avoid some glitches.
 
-   Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2004, 2005, 2006, 2009 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
 #include <unistd.h>
 #include "unistd-safer.h"
 
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
-
 /* Like fopen, but do not return stdin, stdout, or stderr.  */
 
 FILE *
index 05bd4ec..d842c77 100644 (file)
@@ -1,5 +1,5 @@
 /* Creation of subprocesses, communicating via pipes.
-   Copyright (C) 2001-2004, 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2001-2004, 2006-2009 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
 
 #endif
 
-#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-#endif
-#ifndef STDOUT_FILENO
-# define STDOUT_FILENO 1
-#endif
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
-
 /* The results of open() in this file are not used with fchdir,
    therefore save some unnecessary work in fchdir.c.  */
 #undef open
index eec401a..e8d05ae 100644 (file)
@@ -1,5 +1,5 @@
 /* Invoke tmpfile, but avoid some glitches.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009 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
 
 #include "binary-io.h"
 
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
-
 /* Like tmpfile, but do not return stdin, stdout, or stderr.
 
    Remember that tmpfile can leave files behind if your program calls _exit,
index 52db71c..d8276b1 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef _GL_UNISTD_H
 #define _GL_UNISTD_H
 
-/* mingw doesn't define the SEEK_* macros in <unistd.h>.  */
+/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
 # include <stdio.h>
 #endif
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* OS/2 EMX lacks these macros.  */
+#ifndef STDIN_FILENO
+# define STDIN_FILENO 0
+#endif
+#ifndef STDOUT_FILENO
+# define STDOUT_FILENO 1
+#endif
+#ifndef STDERR_FILENO
+# define STDERR_FILENO 2
+#endif
+
 /* Declare overridden functions.  */
 
 #ifdef __cplusplus
index 4f167e4..86e23ab 100644 (file)
@@ -10,6 +10,7 @@ lib/unistd-safer.h
 m4/unistd-safer.m4
 
 Depends-on:
+unistd
 
 configure.ac:
 gl_UNISTD_SAFER
index 0c30b88..d3951eb 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of posix_spawn() function.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 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
 
 extern char **environ;
 
-#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-#endif
-#ifndef STDOUT_FILENO
-# define STDOUT_FILENO 1
-#endif
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
-
 #define CHILD_PROGRAM_FILENAME "test-posix_spawn1.sh"
 
 static int
index 826d38b..ca57713 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of posix_spawn() function.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 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
 
 extern char **environ;
 
-#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-#endif
-#ifndef STDOUT_FILENO
-# define STDOUT_FILENO 1
-#endif
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
-
 #define CHILD_PROGRAM_FILENAME "test-posix_spawn2.sh"
 
 static int
index ec5d468..af71068 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of posix_spawn() function.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 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
 
 extern char **environ;
 
-#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-#endif
-#ifndef STDOUT_FILENO
-# define STDOUT_FILENO 1
-#endif
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
-
 #define CHILD_PROGRAM_FILENAME "test-posix_spawn3"
 #define DATA_FILENAME "t!#$%&'()*+,-;=?@[\\]^_`{|}~.tmp"