/* Synchronous subprocess invocation for GNU Emacs.
- Copyright (C) 1985-1988, 1993-1995, 1999-2011
+ Copyright (C) 1985-1988, 1993-1995, 1999-2012
Free Software Foundation, Inc.
This file is part of GNU Emacs.
#endif /* MSDOS */
#include "commands.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "ccl.h"
#include "coding.h"
#include "composite.h"
static Lisp_Object
call_process_kill (Lisp_Object fdpid)
{
- emacs_close (XFASTINT (Fcar (fdpid)));
- EMACS_KILLPG (XFASTINT (Fcdr (fdpid)), SIGKILL);
+ int fd;
+ pid_t pid;
+ CONS_TO_INTEGER (Fcar (fdpid), int, fd);
+ CONS_TO_INTEGER (Fcdr (fdpid), pid_t, pid);
+ emacs_close (fd);
+ EMACS_KILLPG (pid, SIGKILL);
synch_process_alive = 0;
return Qnil;
}
call_process_cleanup (Lisp_Object arg)
{
Lisp_Object fdpid = Fcdr (arg);
+ int fd;
#if defined (MSDOS)
Lisp_Object file;
- int fd;
#else
- int pid;
+ pid_t pid;
#endif
Fset_buffer (Fcar (arg));
+ CONS_TO_INTEGER (Fcar (fdpid), int, fd);
#if defined (MSDOS)
/* for MSDOS fdpid is really (fd . tempfile) */
- fd = XFASTINT (Fcar (fdpid));
file = Fcdr (fdpid);
/* FD is -1 and FILE is "" when we didn't actually create a
temporary file in call-process. */
if (!(strcmp (SDATA (file), NULL_DEVICE) == 0 || SREF (file, 0) == '\0'))
unlink (SDATA (file));
#else /* not MSDOS */
- pid = XFASTINT (Fcdr (fdpid));
+ CONS_TO_INTEGER (Fcdr (fdpid), pid_t, pid);
if (call_process_exited)
{
- emacs_close (XFASTINT (Fcar (fdpid)));
+ emacs_close (fd);
return Qnil;
}
if (EMACS_KILLPG (pid, SIGINT) == 0)
{
- int count = SPECPDL_INDEX ();
+ ptrdiff_t count = SPECPDL_INDEX ();
record_unwind_protect (call_process_kill, fdpid);
message1 ("Waiting for process to die...(type C-g again to kill it instantly)");
immediate_quit = 1;
message1 ("Waiting for process to die...done");
}
synch_process_alive = 0;
- emacs_close (XFASTINT (Fcar (fdpid)));
+ emacs_close (fd);
#endif /* not MSDOS */
return Qnil;
}
The program's input comes from file INFILE (nil means `/dev/null').
Insert output in BUFFER before point; t means current buffer; nil for BUFFER
means discard it; 0 means discard and don't wait; and `(:file FILE)', where
- FILE is a file name string, means that it should be written to that file.
+ FILE is a file name string, means that it should be written to that file
+ \(if the file already exists it is overwritten).
BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
REAL-BUFFER says what to do with standard output, as above,
while STDERR-FILE says what to do with standard error in the child.
usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
- Lisp_Object infile, buffer, current_dir, path;
- volatile int display_p_volatile;
+ Lisp_Object infile, buffer, current_dir, path, cleanup_info_tail;
+ int display_p;
int fd[2];
int filefd;
- register int pid;
#define CALLPROC_BUFFER_SIZE_MIN (16 * 1024)
#define CALLPROC_BUFFER_SIZE_MAX (4 * CALLPROC_BUFFER_SIZE_MIN)
char buf[CALLPROC_BUFFER_SIZE_MAX];
int bufsize = CALLPROC_BUFFER_SIZE_MIN;
- int count = SPECPDL_INDEX ();
- volatile USE_SAFE_ALLOCA;
+ ptrdiff_t count = SPECPDL_INDEX ();
+ USE_SAFE_ALLOCA;
register const unsigned char **new_argv;
/* File to use for stderr in the child.
#ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */
char *outf, *tempfile = NULL;
int outfilefd;
+ int pid;
+#else
+ pid_t pid;
#endif
int fd_output = -1;
struct coding_system process_coding; /* coding-system of process output */
UNGCPRO;
}
- display_p_volatile = INTERACTIVE && nargs >= 4 && !NILP (args[3]);
+ display_p = INTERACTIVE && nargs >= 4 && !NILP (args[3]);
filefd = emacs_open (SSDATA (infile), O_RDONLY, 0);
if (filefd < 0)
Lisp_Object volatile buffer_volatile = buffer;
Lisp_Object volatile coding_systems_volatile = coding_systems;
Lisp_Object volatile current_dir_volatile = current_dir;
+ int volatile display_p_volatile = display_p;
int volatile fd1_volatile = fd1;
int volatile fd_error_volatile = fd_error;
int volatile fd_output_volatile = fd_output;
int volatile output_to_buffer_volatile = output_to_buffer;
+ int volatile sa_must_free_volatile = sa_must_free;
+ ptrdiff_t volatile sa_count_volatile = sa_count;
unsigned char const **volatile new_argv_volatile = new_argv;
pid = vfork ();
buffer = buffer_volatile;
coding_systems = coding_systems_volatile;
current_dir = current_dir_volatile;
+ display_p = display_p_volatile;
fd1 = fd1_volatile;
fd_error = fd_error_volatile;
fd_output = fd_output_volatile;
output_to_buffer = output_to_buffer_volatile;
+ sa_must_free = sa_must_free_volatile;
+ sa_count = sa_count_volatile;
new_argv = new_argv_volatile;
}
/* GConf causes us to ignore SIGPIPE, make sure it is restored
in the child. */
- //signal (SIGPIPE, SIG_DFL);
+ signal (SIGPIPE, SIG_DFL);
#ifdef HAVE_WORKING_VFORK
pthread_sigmask (SIG_SETMASK, &procmask, 0);
#endif
#if defined (MSDOS)
/* MSDOS needs different cleanup information. */
- record_unwind_protect (call_process_cleanup,
- Fcons (Fcurrent_buffer (),
- Fcons (make_number (fd[0]),
- build_string (tempfile ? tempfile : ""))));
+ cleanup_info_tail = build_string (tempfile ? tempfile : "");
#else
+ cleanup_info_tail = INTEGER_TO_CONS (pid);
+#endif /* not MSDOS */
record_unwind_protect (call_process_cleanup,
Fcons (Fcurrent_buffer (),
- Fcons (make_number (fd[0]), make_number (pid))));
-#endif /* not MSDOS */
-
+ Fcons (INTEGER_TO_CONS (fd[0]),
+ cleanup_info_tail)));
if (BUFFERP (buffer))
Fset_buffer (buffer);
/* If BUFFER is nil, we must read process output once and then
discard it, so setup coding system but with nil. */
setup_coding_system (Qnil, &process_coding);
+ process_coding.dst_multibyte = 0;
}
else
{
&& !NILP (val))
val = raw_text_coding_system (val);
setup_coding_system (val, &process_coding);
+ process_coding.dst_multibyte
+ = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
}
+ process_coding.src_multibyte = 0;
immediate_quit = 1;
QUIT;
if (output_to_buffer)
{
- register EMACS_INT nread;
+ register int nread;
int first = 1;
EMACS_INT total_read = 0;
int carryover = 0;
- int display_p = display_p_volatile;
int display_on_the_fly = display_p;
struct coding_system saved_coding;
else
{ /* We have to decode the input. */
Lisp_Object curbuf;
- int count1 = SPECPDL_INDEX ();
+ ptrdiff_t count1 = SPECPDL_INDEX ();
XSETBUFFER (curbuf, current_buffer);
/* We cannot allow after-change-functions be run
delete_temp_file (Lisp_Object name)
{
/* Suppress jka-compr handling, etc. */
- int count = SPECPDL_INDEX ();
+ ptrdiff_t count = SPECPDL_INDEX ();
specbind (intern ("file-name-handler-alist"), Qnil);
internal_delete_file (name);
unbind_to (count, Qnil);
Insert output in BUFFER before point; t means current buffer; nil for
BUFFER means discard it; 0 means discard and don't wait; and `(:file
FILE)', where FILE is a file name string, means that it should be
- written to that file.
+ written to that file (if the file already exists it is overwritten).
BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
REAL-BUFFER says what to do with standard output, as above,
while STDERR-FILE says what to do with standard error in the child.
struct gcpro gcpro1;
Lisp_Object filename_string;
register Lisp_Object start, end;
- int count = SPECPDL_INDEX ();
+ ptrdiff_t count = SPECPDL_INDEX ();
/* Qt denotes we have not yet called Ffind_operation_coding_system. */
Lisp_Object coding_systems;
Lisp_Object val, *args2;
UNBLOCK_INPUT;
if (fd == -1)
report_file_error ("Failed to open temporary file",
- Fcons (Vtemp_file_name_pattern, Qnil));
+ Fcons (build_string (tempfile), Qnil));
else
close (fd);
}
val = complement_process_encoding_system (val);
{
- int count1 = SPECPDL_INDEX ();
+ ptrdiff_t count1 = SPECPDL_INDEX ();
specbind (intern ("coding-system-for-write"), val);
/* POSIX lets mk[s]temp use "."; don't invoke jka-compr if we
HANDLE handles[3];
#endif /* WINDOWSNT */
- int pid = getpid ();
+ pid_t pid = getpid ();
/* Close Emacs's descriptors that this process should not have. */
close_process_descs ();
staticpro (&Vtemp_file_name_pattern);
DEFVAR_LISP ("shell-file-name", Vshell_file_name,
- doc: /* *File name to load inferior shells from.
+ doc: /* File name to load inferior shells from.
Initialized from the SHELL environment variable, or to a system-dependent
default if SHELL is not set. */);
DEFVAR_LISP ("exec-path", Vexec_path,
- doc: /* *List of directories to search programs to run in subprocesses.
+ doc: /* List of directories to search programs to run in subprocesses.
Each element is a string (directory name) or nil (try default directory). */);
DEFVAR_LISP ("exec-suffixes", Vexec_suffixes,
- doc: /* *List of suffixes to try to find executable file names.
+ doc: /* List of suffixes to try to find executable file names.
Each element is a string. */);
Vexec_suffixes = Qnil;