summaryrefslogtreecommitdiff
path: root/src/callproc.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/callproc.c
parent0773c610689c7612b0d7b44e61701079b6f56419 (diff)
downloademacs-406af475be236b874e3633b68999f6a099d47587.tar.gz
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/callproc.c')
-rw-r--r--src/callproc.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/callproc.c b/src/callproc.c
index f0aa8222342..6de8113dc14 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -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)
{