summaryrefslogtreecommitdiff
path: root/src/unexelf.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-07-05 19:40:50 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-07-05 19:40:50 -0700
commit406af475be236b874e3633b68999f6a099d47587 (patch)
tree4dfc0e61b3fce353adedc96f84091aca4ae23b57 /src/unexelf.c
parent0773c610689c7612b0d7b44e61701079b6f56419 (diff)
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.
Diffstat (limited to 'src/unexelf.c')
-rw-r--r--src/unexelf.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/unexelf.c b/src/unexelf.c
index 4e50bb8636..28847157e4 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -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));