]> code.delx.au - gnu-emacs/commitdiff
Use emacs_open more consistently when opening files.
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Jul 2013 02:40:50 +0000 (19:40 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Jul 2013 02:40:50 +0000 (19:40 -0700)
This handles EINTR more consistently now, and makes it easier
to introduce other uniform changes to file descriptor handling.
* src/systdio.h: New file.
* src/buffer.c (mmap_init):
* cygw32.c (chdir_to_default_directory):
* dispnew.c (Fopen_termscript):
* emacs.c (Fdaemon_initialized):
* fileio.c (Fdo_auto_save):
* image.c (slurp_file, png_load_body, jpeg_load_body):
* keyboard.c (Fopen_dribble_file):
* lread.c (Fload):
* print.c (Fredirect_debugging_output):
* sysdep.c (get_up_time, procfs_ttyname, procfs_get_total_memory):
* termcap.c (tgetent):
* unexaix.c, unexcoff.c (unexec, adjust_lnnoptrs):
* unexcw.c, unexelf.c, unexhp9k800.c, unexmacosx.c (unexec):
* w32term.c (w32_initialize) [CYGWIN]:
* xfaces.c (Fx_load_color_file):
Use emacs_open instead of plain open, and emacs_fopen instead of
plain fopen.
* dispnew.c, fileio.c, image.c, keyboard.c, lread.c, print.c, sysdep.c:
* xfaces.c: Include sysstdio.h rather than stdio.h, for emacs_fopen.
* callproc.c (default_output_mode): New constant.
(Fcall_process): Use it to call emacs_open instead of plain creat.
* dispnew.c (Fopen_termscript): Fix minor race in opening termscript.
* sysdep.c (emacs_open): Add commentary and don't call file name "path".
(emacs_fopen): New function.
* unexaix.c, unexcoff.c, unexelf.c, unexhp9k800.c, unexmacosx.c:
Include <lisp.h>, for emacs_open.
* unexelf.c (fatal): Remove decl; not needed with <lisp.h> included.

23 files changed:
src/ChangeLog
src/buffer.c
src/callproc.c
src/cygw32.c
src/dispnew.c
src/emacs.c
src/fileio.c
src/image.c
src/keyboard.c
src/lread.c
src/print.c
src/sysdep.c
src/sysstdio.h [new file with mode: 0644]
src/term.c
src/termcap.c
src/unexaix.c
src/unexcoff.c
src/unexcw.c
src/unexelf.c
src/unexhp9k800.c
src/unexmacosx.c
src/w32term.c
src/xfaces.c

index d42f5733ce63cb3d89706e43ed912ad7b9cf006b..0465bdcaf2e2728201f85c0b8a244406313235c8 100644 (file)
@@ -1,5 +1,37 @@
 2013-07-05  Paul Eggert  <eggert@cs.ucla.edu>
 
+       Use emacs_open more consistently when opening files.
+       This handles EINTR more consistently now, and makes it easier
+       to introduce other uniform changes to file descriptor handling.
+       * src/systdio.h: New file.
+       * src/buffer.c (mmap_init):
+       * cygw32.c (chdir_to_default_directory):
+       * dispnew.c (Fopen_termscript):
+       * emacs.c (Fdaemon_initialized):
+       * fileio.c (Fdo_auto_save):
+       * image.c (slurp_file, png_load_body, jpeg_load_body):
+       * keyboard.c (Fopen_dribble_file):
+       * lread.c (Fload):
+       * print.c (Fredirect_debugging_output):
+       * sysdep.c (get_up_time, procfs_ttyname, procfs_get_total_memory):
+       * termcap.c (tgetent):
+       * unexaix.c, unexcoff.c (unexec, adjust_lnnoptrs):
+       * unexcw.c, unexelf.c, unexhp9k800.c, unexmacosx.c (unexec):
+       * w32term.c (w32_initialize) [CYGWIN]:
+       * xfaces.c (Fx_load_color_file):
+       Use emacs_open instead of plain open, and emacs_fopen instead of
+       plain fopen.
+       * dispnew.c, fileio.c, image.c, keyboard.c, lread.c, print.c, sysdep.c:
+       * xfaces.c: Include sysstdio.h rather than stdio.h, for emacs_fopen.
+       * callproc.c (default_output_mode): New constant.
+       (Fcall_process): Use it to call emacs_open instead of plain creat.
+       * dispnew.c (Fopen_termscript): Fix minor race in opening termscript.
+       * sysdep.c (emacs_open): Add commentary and don't call file name "path".
+       (emacs_fopen): New function.
+       * unexaix.c, unexcoff.c, unexelf.c, unexhp9k800.c, unexmacosx.c:
+       Include <lisp.h>, for emacs_open.
+       * unexelf.c (fatal): Remove decl; not needed with <lisp.h> included.
+
        Remove duplicate #include directives.
        * alloc.c [GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES]:
        * xfaces.c:
index 64b1bce9b0074fba16f246f889ed584671a3dc57..94104ef535c24095ee70c8d621e324db7e1ea5c7 100644 (file)
@@ -4726,7 +4726,7 @@ mmap_init (void)
   if (mmap_fd <= 0)
     {
       /* No anonymous mmap -- we need the file descriptor.  */
-      mmap_fd = open ("/dev/zero", O_RDONLY);
+      mmap_fd = emacs_open ("/dev/zero", O_RDONLY, 0);
       if (mmap_fd == -1)
        fatal ("Cannot open /dev/zero: %s", emacs_strerror (errno));
     }
index f0aa8222342c05b59c00987ad1bde33c1ffc246a..6de8113dc146d01809692d8a624bf15a34e3d832 100644 (file)
@@ -186,6 +186,12 @@ call_process_cleanup (Lisp_Object arg)
   return Qnil;
 }
 
+#ifdef DOS_NT
+static mode_t const default_output_mode = S_IREAD | S_IWRITE;
+#else
+static mode_t const default_output_mode = 0666;
+#endif
+
 DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0,
        doc: /* Call PROGRAM synchronously in separate process.
 The remaining arguments are optional.
@@ -407,13 +413,9 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS)  *
 
   if (STRINGP (output_file))
     {
-#ifdef DOS_NT
       fd_output = emacs_open (SSDATA (output_file),
-                             O_WRONLY | O_TRUNC | O_CREAT | O_TEXT,
-                             S_IREAD | S_IWRITE);
-#else  /* not DOS_NT */
-      fd_output = creat (SSDATA (output_file), 0666);
-#endif /* not DOS_NT */
+                             O_WRONLY | O_CREAT | O_TRUNC | O_TEXT,
+                             default_output_mode);
       if (fd_output < 0)
        {
          output_file = DECODE_FILE (output_file);
@@ -492,7 +494,8 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS)  *
        strcat (tempfile, "/");
       strcat (tempfile, "detmp.XXX");
       mktemp (tempfile);
-      outfilefd = creat (tempfile, S_IREAD | S_IWRITE);
+      outfilefd = emacs_open (tempfile, O_WRONLY | O_CREAT | O_TRUNC,
+                             S_IREAD | S_IWRITE);
       if (outfilefd < 0) {
        emacs_close (filefd);
        report_file_error ("Opening process output file",
@@ -535,15 +538,9 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS)  *
     if (NILP (error_file))
       fd_error = emacs_open (NULL_DEVICE, O_WRONLY, 0);
     else if (STRINGP (error_file))
-      {
-#ifdef DOS_NT
-       fd_error = emacs_open (SSDATA (error_file),
-                              O_WRONLY | O_TRUNC | O_CREAT | O_TEXT,
-                              S_IREAD | S_IWRITE);
-#else  /* not DOS_NT */
-       fd_error = creat (SSDATA (error_file), 0666);
-#endif /* not DOS_NT */
-      }
+      fd_error = emacs_open (SSDATA (error_file),
+                            O_WRONLY | O_CREAT | O_TRUNC | O_TEXT,
+                            default_output_mode);
 
     if (fd_error < 0)
       {
index a7dbdaed6150292d044cef04ad373722dffcadf3..bbc3a49fd886f61e6c867d61439f587df9d7db43 100644 (file)
@@ -35,7 +35,7 @@ static void
 chdir_to_default_directory ()
 {
   Lisp_Object new_cwd;
-  int old_cwd_fd = open (".", O_RDONLY | O_DIRECTORY);
+  int old_cwd_fd = emacs_open (".", O_RDONLY | O_DIRECTORY, 0);
 
   if (old_cwd_fd == -1)
     error ("could not open current directory: %s", strerror (errno));
index b4ca654a8f7d5b6acff027a8426b565fe93d78bd..31b8a1310ea187f2c70cddf61b14ac8d355cf33c 100644 (file)
@@ -22,7 +22,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #define DISPEXTERN_INLINE EXTERN_INLINE
 
-#include <stdio.h>
+#include "sysstdio.h"
 #include <unistd.h>
 
 #include "lisp.h"
@@ -5605,17 +5605,17 @@ FILE = nil means just close any termscript file currently open.  */)
   tty = CURTTY ();
 
   if (tty->termscript != 0)
-  {
-    block_input ();
-    fclose (tty->termscript);
-    unblock_input ();
-  }
-  tty->termscript = 0;
+    {
+      block_input ();
+      fclose (tty->termscript);
+      tty->termscript = 0;
+      unblock_input ();
+    }
 
   if (! NILP (file))
     {
       file = Fexpand_file_name (file, Qnil);
-      tty->termscript = fopen (SSDATA (file), "w");
+      tty->termscript = emacs_fopen (SSDATA (file), "w");
       if (tty->termscript == 0)
        report_file_error ("Opening termscript", Fcons (file, Qnil));
     }
index 4b709527ff064cd3917ddb1c6e1bc1741e3fe36f..6ba01d1a4434a2571be3a557483b437fa082e413 100644 (file)
@@ -2236,7 +2236,7 @@ from the parent process and its tty file descriptors.  */)
     error ("This function can only be called after loading the init files");
 
   /* Get rid of stdin, stdout and stderr.  */
-  nfd = open ("/dev/null", O_RDWR);
+  nfd = emacs_open ("/dev/null", O_RDWR, 0);
   err |= nfd < 0;
   err |= dup2 (nfd, 0) < 0;
   err |= dup2 (nfd, 1) < 0;
index 0ba7f85da2c10ada1068f9c61077e794b9afb0e9..89ae89e1613a17189a9cc2d2b93ada880cda536b 100644 (file)
@@ -20,7 +20,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include <limits.h>
 #include <fcntl.h>
-#include <stdio.h>
+#include "sysstdio.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -5618,7 +5618,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
          UNGCPRO;
        }
 
-      stream = fopen (SSDATA (listfile), "w");
+      stream = emacs_fopen (SSDATA (listfile), "w");
     }
 
   record_unwind_protect (do_auto_save_unwind,
index a3e103f9559a2861a135c0c54c811df66ba2e041..7ecd59d27b4e62c89788ba3e51cc63356a4e010b 100644 (file)
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
-#include <stdio.h>
+#include "sysstdio.h"
 #include <unistd.h>
 
 #ifdef HAVE_PNG
@@ -2274,7 +2274,7 @@ x_find_image_file (Lisp_Object file)
 static unsigned char *
 slurp_file (char *file, ptrdiff_t *size)
 {
-  FILE *fp = fopen (file, "rb");
+  FILE *fp = emacs_fopen (file, "rb");
   unsigned char *buf = NULL;
   struct stat st;
 
@@ -5723,7 +5723,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
        }
 
       /* Open the image file.  */
-      fp = fopen (SSDATA (file), "rb");
+      fp = emacs_fopen (SSDATA (file), "rb");
       if (!fp)
        {
          image_error ("Cannot open image file `%s'", file, Qnil);
@@ -6484,7 +6484,7 @@ jpeg_load_body (struct frame *f, struct image *img,
          return 0;
        }
 
-      fp = fopen (SSDATA (file), "rb");
+      fp = emacs_fopen (SSDATA (file), "rb");
       if (fp == NULL)
        {
          image_error ("Cannot open `%s'", file, Qnil);
index e6094a939b9733553e824689a47553d4b1a29723..39535f5cd714b6785f99b6e24ce4de8de68313cc 100644 (file)
@@ -23,7 +23,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #define BLOCKINPUT_INLINE EXTERN_INLINE
 #define KEYBOARD_INLINE EXTERN_INLINE
 
-#include <stdio.h>
+#include "sysstdio.h"
 
 #include "lisp.h"
 #include "termchar.h"
@@ -10129,7 +10129,7 @@ The file will be closed when Emacs exits.  */)
   if (!NILP (file))
     {
       file = Fexpand_file_name (file, Qnil);
-      dribble = fopen (SSDATA (file), "w");
+      dribble = emacs_fopen (SSDATA (file), "w");
       if (dribble == 0)
        report_file_error ("Opening dribble", Fcons (file, Qnil));
     }
index 5f7b2cbdbe284e5c8a15476d55d9ec329bdac52d..06badce12be61e2e4bb3ad89f86473b16dad984e 100644 (file)
@@ -20,7 +20,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 #include <config.h>
-#include <stdio.h>
+#include "sysstdio.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/file.h>
@@ -1297,7 +1297,7 @@ Return t if the file exists and loads successfully.  */)
   if (fd >= 0)
     {
       emacs_close (fd);
-      stream = fopen (SSDATA (efound), fmode);
+      stream = emacs_fopen (SSDATA (efound), fmode);
     }
   else
     stream = NULL;
index b1eec4c48d4addd2d14d610667d9b72f864ff175..a16f3b32f46638b376cd1e6c5a44d5d084e999fb 100644 (file)
@@ -20,7 +20,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 #include <config.h>
-#include <stdio.h>
+#include "sysstdio.h"
 
 #include "lisp.h"
 #include "character.h"
@@ -765,7 +765,7 @@ append to existing target file.  */)
     {
       file = Fexpand_file_name (file, Qnil);
       initial_stderr_stream = stderr;
-      stderr = fopen (SSDATA (file), NILP (append) ? "w" : "a");
+      stderr = emacs_fopen (SSDATA (file), NILP (append) ? "w" : "a");
       if (stderr == NULL)
        {
          stderr = initial_stderr_stream;
index 11b2dbfd61721d50de9b3546cb4170cdd284bc4e..91e941a2050c22ec695b0951c099a9b1e4444f9e 100644 (file)
@@ -22,7 +22,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #define SYSTIME_INLINE EXTERN_INLINE
 
 #include <execinfo.h>
-#include <stdio.h>
+#include "sysstdio.h"
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 #include <grp.h>
@@ -2151,15 +2151,29 @@ emacs_abort (void)
 }
 #endif
 
+/* Open FILE for Emacs use, using open flags OFLAG and mode MODE.
+   Do not fail merely because the open was interrupted by a signal.
+   Allow the user to quit.  */
+
 int
-emacs_open (const char *path, int oflag, int mode)
+emacs_open (const char *file, int oflags, int mode)
 {
-  register int rtnval;
+  int fd;
+  while ((fd = open (file, oflags, mode)) < 0 && errno == EINTR)
+    QUIT;
+  return fd;
+}
 
-  while ((rtnval = open (path, oflag, mode)) == -1
-        && (errno == EINTR))
+/* Open FILE as a stream for Emacs use, with mode MODE.
+   Act like emacs_open with respect to threads, signals, and quits.  */
+
+FILE *
+emacs_fopen (char const *file, char const *mode)
+{
+  FILE *fp;
+  while (! (fp = fopen (file, mode)) && errno == EINTR)
     QUIT;
-  return (rtnval);
+  return fp;
 }
 
 int
@@ -2637,7 +2651,7 @@ get_up_time (void)
   EMACS_TIME up = make_emacs_time (0, 0);
 
   block_input ();
-  fup = fopen ("/proc/uptime", "r");
+  fup = emacs_fopen ("/proc/uptime", "r");
 
   if (fup)
     {
@@ -2682,7 +2696,7 @@ procfs_ttyname (int rdev)
   char name[PATH_MAX];
 
   block_input ();
-  fdev = fopen ("/proc/tty/drivers", "r");
+  fdev = emacs_fopen ("/proc/tty/drivers", "r");
 
   if (fdev)
     {
@@ -2724,7 +2738,7 @@ procfs_get_total_memory (void)
   unsigned long retval = 2 * 1024 * 1024; /* default: 2GB */
 
   block_input ();
-  fmem = fopen ("/proc/meminfo", "r");
+  fmem = emacs_fopen ("/proc/meminfo", "r");
 
   if (fmem)
     {
diff --git a/src/sysstdio.h b/src/sysstdio.h
new file mode 100644 (file)
index 0000000..e9dfb69
--- /dev/null
@@ -0,0 +1,2 @@
+#include <stdio.h>
+extern FILE *emacs_fopen (char const *, char const *);
index 0bcef55947a85f6b374c54c79d148e38f0ab55f8..39d143564c6171f9a9ae54e9a7579eb9f369e8a8 100644 (file)
@@ -2479,7 +2479,7 @@ term_mouse_moveto (int x, int y)
   const char *name;
   int fd;
   name = (const char *) ttyname (0);
-  fd = open (name, O_WRONLY);
+  fd = emacs_open (name, O_WRONLY, 0);
      SOME_FUNCTION (x, y, fd);
   close (fd);
   last_mouse_x = x;
index 99bbfce27f5e26cb849723f5530ab5bfa840fd52..7256eef9e8154cabb2a74a4fc40bd054dbf5d792 100644 (file)
@@ -427,11 +427,7 @@ tgetent (char *bp, const char *name)
 
   /* Here we know we must search a file and termcap_name has its name.  */
 
-#ifdef MSDOS
-  fd = open (termcap_name, O_RDONLY|O_TEXT, 0);
-#else
-  fd = open (termcap_name, O_RDONLY, 0);
-#endif
+  fd = emacs_open (termcap_name, O_RDONLY | O_TEXT, 0);
   if (fd < 0)
     return -1;
 
index 44a824b8c12d2a25c3915b64f328d8f955916902..204f6cf4ad3787c32d01596a349889f9c1e20bc4 100644 (file)
@@ -42,6 +42,7 @@ what you give them.   Help stamp out software-hoarding!  */
 
 #include <config.h>
 #include "unexec.h"
+#include "lisp.h"
 
 #define PERROR(file) report_error (file, new)
 #include <a.out.h>
@@ -132,11 +133,11 @@ unexec (const char *new_name, const char *a_name)
 {
   int new = -1, a_out = -1;
 
-  if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
+  if (a_name && (a_out = emacs_open (a_name, O_RDONLY, 0)) < 0)
     {
       PERROR (a_name);
     }
-  if ((new = creat (new_name, 0666)) < 0)
+  if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
     {
       PERROR (new_name);
     }
@@ -503,7 +504,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
   if (!lnnoptr || !f_hdr.f_symptr)
     return 0;
 
-  if ((new = open (new_name, O_RDWR)) < 0)
+  if ((new = emacs_open (new_name, O_RDWR, 0)) < 0)
     {
       PERROR (new_name);
       return -1;
index 2e662a34145fdb91c76c7fa4e465142665475bc0..e79821251bac59b8590faca4bbb90eae208d63d3 100644 (file)
@@ -52,6 +52,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include "unexec.h"
+#include "lisp.h"
 
 #define PERROR(file) report_error (file, new)
 
@@ -486,7 +487,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
 #ifdef MSDOS
   if ((new = writedesc) < 0)
 #else
-  if ((new = open (new_name, O_RDWR)) < 0)
+  if ((new = emacs_open (new_name, O_RDWR, 0)) < 0)
 #endif
     {
       PERROR (new_name);
@@ -525,11 +526,11 @@ unexec (const char *new_name, const char *a_name)
 {
   int new = -1, a_out = -1;
 
-  if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
+  if (a_name && (a_out = emacs_open (a_name, O_RDONLY, 0)) < 0)
     {
       PERROR (a_name);
     }
-  if ((new = creat (new_name, 0666)) < 0)
+  if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
     {
       PERROR (new_name);
     }
index 1290c28d2454179292c914bc5488884b4e5370a7..0312a7328fbcd142c1475ca2126c02d0aa51a1fc 100644 (file)
@@ -20,8 +20,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include "unexec.h"
+#include "lisp.h"
 
-#include <lisp.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <a.out.h>
@@ -298,9 +298,9 @@ unexec (const char *outfile, const char *infile)
   infile = add_exe_suffix_if_necessary (infile, infile_buffer);
   outfile = add_exe_suffix_if_necessary (outfile, outfile_buffer);
 
-  fd_in = open (infile, O_RDONLY | O_BINARY);
+  fd_in = emacs_open (infile, O_RDONLY | O_BINARY, 0);
   assert (fd_in >= 0);
-  fd_out = open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755);
+  fd_out = emacs_open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755);
   assert (fd_out >= 0);
   for (;;)
     {
index 4e50bb86367d9b16f341c8e1f78a861f62a8b978..28847157e40fd1033d247462ddb40148aeb0fe3f 100644 (file)
@@ -386,9 +386,8 @@ temacs:
    Instead we read the whole file, modify it, and write it out.  */
 
 #include <config.h>
-#include <unexec.h>
-
-extern _Noreturn void fatal (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
+#include "unexec.h"
+#include "lisp.h"
 
 #include <errno.h>
 #include <fcntl.h>
@@ -672,7 +671,7 @@ unexec (const char *new_name, const char *old_name)
   /* Open the old file, allocate a buffer of the right size, and read
      in the file contents.  */
 
-  old_file = open (old_name, O_RDONLY);
+  old_file = emacs_open (old_name, O_RDONLY, 0);
 
   if (old_file < 0)
     fatal ("Can't open %s for reading: %s", old_name, strerror (errno));
@@ -681,7 +680,7 @@ unexec (const char *new_name, const char *old_name)
     fatal ("Can't fstat (%s): %s", old_name, strerror (errno));
 
 #if MAP_ANON == 0
-  mmap_fd = open ("/dev/zero", O_RDONLY);
+  mmap_fd = emacs_open ("/dev/zero", O_RDONLY, 0);
   if (mmap_fd < 0)
     fatal ("Can't open /dev/zero for reading: %s", strerror (errno));
 #endif
@@ -801,7 +800,7 @@ unexec (const char *new_name, const char *old_name)
      the image of the new file.  Set pointers to various interesting
      objects.  */
 
-  new_file = open (new_name, O_RDWR | O_CREAT, 0666);
+  new_file = emacs_open (new_name, O_RDWR | O_CREAT, 0666);
   if (new_file < 0)
     fatal ("Can't creat (%s): %s", new_name, strerror (errno));
 
index ce65faffd4e59d73b3f9e88b90bc945375efaaa9..0f6eb87ee017971c27ca4a664284e66ac838a336 100644 (file)
@@ -51,6 +51,7 @@
 \f
 #include <config.h>
 #include "unexec.h"
+#include "lisp.h"
 
 #include <stdio.h>
 #include <fcntl.h>
@@ -268,10 +269,10 @@ unexec (const char *new_name,      /* name of the new a.out file to be created *
      intact.  NOT implemented.  */
 
   /* Open the input and output a.out files */
-  old = open (old_name, O_RDONLY);
+  old = emacs_open (old_name, O_RDONLY, 0);
   if (old < 0)
     { perror (old_name); exit (1); }
-  new = open (new_name, O_CREAT|O_RDWR|O_TRUNC, 0777);
+  new = emacs_open (new_name, O_CREAT | O_RDWR | O_TRUNC, 0777);
   if (new < 0)
     { perror (new_name); exit (1); }
 
index 8d4e636fa5cd329033684190e9fdb98049b4fadb..2bc6de177ebe472a24d515f820a0de81cd1cc38b 100644 (file)
@@ -97,6 +97,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #undef free
 
 #include "unexec.h"
+#include "lisp.h"
 
 #include <stdio.h>
 #include <fcntl.h>
@@ -1322,13 +1323,13 @@ unexec (const char *outfile, const char *infile)
     unexec_error ("Unexec from a dumped executable is not supported.");
 
   pagesize = getpagesize ();
-  infd = open (infile, O_RDONLY, 0);
+  infd = emacs_open (infile, O_RDONLY, 0);
   if (infd < 0)
     {
       unexec_error ("cannot open input file `%s'", infile);
     }
 
-  outfd = open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755);
+  outfd = emacs_open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755);
   if (outfd < 0)
     {
       close (infd);
index fcd5886d5c9cf169a2d974be9bf0385f05b0e0b6..c9951ca1d52a61b9b88ab6a7213acdd8d0facf1a 100644 (file)
@@ -6621,7 +6621,7 @@ w32_initialize (void)
     }
 
 #ifdef CYGWIN
-  if ((w32_message_fd = open ("/dev/windows", O_RDWR | O_CLOEXEC)) == -1)
+  if ((w32_message_fd = emacs_open ("/dev/windows", O_RDWR, 0)) == -1)
     fatal ("opening /dev/windows: %s", strerror (errno));
 #endif /* CYGWIN */
 
index 0c627d7f9ee7449ac76bd53f904051d3d3bb744b..4b42cb7dc409fb97c438af08fb41d47d7224e1c8 100644 (file)
@@ -200,7 +200,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    used to fill in unspecified attributes of the default face.  */
 
 #include <config.h>
-#include <stdio.h>
+#include "sysstdio.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -6290,7 +6290,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string.  */)
   CHECK_STRING (filename);
   abspath = Fexpand_file_name (filename, Qnil);
 
-  fp = fopen (SSDATA (abspath), "rt");
+  fp = emacs_fopen (SSDATA (abspath), "rt");
   if (fp)
     {
       char buf[512];