/* Synchronous subprocess invocation for GNU Emacs.
Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
Lisp_Object Qbuffer_file_type;
#endif /* DOS_NT */
-/* True iff we are about to fork off a synchronous process or if we
+/* True if we are about to fork off a synchronous process or if we
are waiting for it. */
int synch_process_alive;
#ifdef HAVE_MKSTEMP
{
- int fd = mkstemp (tempfile);
+ int fd;
+
+ BLOCK_INPUT;
+ fd = mkstemp (tempfile);
+ UNBLOCK_INPUT;
if (fd == -1)
report_file_error ("Failed to open temporary file",
Fcons (Vtemp_file_name_pattern, Qnil));
{
char **env;
char *pwd_var;
+ char *term_var;
+ char *display_var;
#ifdef WINDOWSNT
int cpid;
HANDLE handles[3];
register char **new_env;
char **p, **q;
register int new_length;
- Lisp_Object local = get_frame_param (XFRAME (Fframe_with_environment (selected_frame)),
- Qenvironment);
+ Lisp_Object local = selected_frame; /* get_frame_param (XFRAME (Fframe_with_environment (selected_frame)), */
+/* Qenvironment); */
+ Lisp_Object term;
+ Lisp_Object display;
+
new_length = 0;
for (tem = Vprocess_environment;
tem = XCDR (tem))
new_length++;
+#if 0
for (tem = local;
CONSP (tem) && STRINGP (XCAR (tem));
tem = XCDR (tem))
new_length++;
+#endif
+
+ /* Add TERM and DISPLAY from the frame local values. */
+ term = get_frame_param (XFRAME (local), Qterm_environment_variable);
+ if (! NILP (term))
+ new_length++;
+
+ display = get_frame_param (XFRAME (local), Qdisplay_environment_variable);
+ if (! NILP (display))
+ new_length++;
/* new_length + 2 to include PWD and terminating 0. */
env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *));
if (egetenv ("PWD"))
*new_env++ = pwd_var;
+ if (! NILP (term))
+ {
+ int vlen = strlen ("TERM=") + strlen (SDATA (term)) + 1;
+ char *vdata = (char *) alloca (vlen);
+ strcpy (vdata, "TERM=");
+ strcat (vdata, SDATA (term));
+ new_env = add_env (env, new_env, vdata);
+ }
+
+ if (! NILP (display))
+ {
+ int vlen = strlen ("DISPLAY=") + strlen (SDATA (display)) + 1;
+ char *vdata = (char *) alloca (vlen);
+ strcpy (vdata, "DISPLAY=");
+ strcat (vdata, SDATA (display));
+ new_env = add_env (env, new_env, vdata);
+ }
+
/* Overrides. */
for (tem = Vprocess_environment;
CONSP (tem) && STRINGP (XCAR (tem));
tem = XCDR (tem))
- new_env = add_env (env, new_env, SDATA (XCAR (tem)));
+ {
+ if ((strcmp (SDATA (XCAR (tem)), "TERM") != 0)
+ && (strcmp (SDATA (XCAR (tem)), "DISPLAY") != 0))
+ new_env = add_env (env, new_env, SDATA (XCAR (tem)));
+ }
+
+#if 0
/* Local part of environment. */
for (tem = local;
CONSP (tem) && STRINGP (XCAR (tem));
tem = XCDR (tem))
new_env = add_env (env, new_env, SDATA (XCAR (tem)));
-
+#endif
+
*new_env = 0;
/* Remove variable names without values. */
p++;
}
}
+
+
#ifdef WINDOWSNT
prepare_standard_handles (in, out, err, handles);
set_process_dir (SDATA (current_dir));
Lisp_Object frame;
{
Lisp_Object scan;
+ Lisp_Object term;
+ Lisp_Object display;
+
if (NILP (frame))
{
frame = selected_frame;
}
+ /* For TERM and DISPLAY first try to get the values from the frame. */
+ term = get_frame_param (XFRAME (frame), Qterm_environment_variable);
+ if (strcmp (var, "TERM") == 0)
+ if (! NILP (term))
+ {
+ *value = (char *) SDATA (term);
+ *valuelen = SBYTES (term);
+ return 1;
+ }
+ display = get_frame_param (XFRAME (frame), Qdisplay_environment_variable);
+ if (strcmp (var, "DISPLAY") == 0)
+ if (! NILP (display))
+ {
+ *value = (char *) SDATA (display);
+ *valuelen = SBYTES (display);
+ return 1;
+ }
+
+ {
+ /* Try to find VAR in Vprocess_environment. */
+ for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan))
+ {
+ Lisp_Object entry = XCAR (scan);
+ if (STRINGP (entry)
+ && SBYTES (entry) >= varlen
+#ifdef WINDOWSNT
+ /* NT environment variables are case insensitive. */
+ && ! strnicmp (SDATA (entry), var, varlen)
+#else /* not WINDOWSNT */
+ && ! bcmp (SDATA (entry), var, varlen)
+#endif /* not WINDOWSNT */
+ )
+ {
+ if (SBYTES (entry) > varlen && SREF (entry, varlen) == '=')
+ {
+ *value = (char *) SDATA (entry) + (varlen + 1);
+ *valuelen = SBYTES (entry) - (varlen + 1);
+ return 1;
+ }
+ else if (SBYTES (entry) == varlen)
+ {
+ /* Lone variable names in Vprocess_environment mean that
+ variable should be removed from the environment. */
+ return 0;
+ }
+ }
+ }
+ }
+
+#if 0
/* Find the environment in which to search the variable. */
CHECK_FRAME (frame);
frame = Fframe_with_environment (frame);
return 1;
}
}
-
+#endif
return 0;
}
set_initial_environment ()
{
register char **envp;
- Lisp_Object env = Qnil;
+ Lisp_Object env = Vprocess_environment;
#ifndef CANNOT_DUMP
if (initialized)
#endif
{
for (envp = environ; *envp; envp++)
- env = Fcons (build_string (*envp), env);
- store_frame_param (SELECTED_FRAME(), Qenvironment, env);
+ Vprocess_environment = Fcons (build_string (*envp),
+ Vprocess_environment);
+ store_frame_param (SELECTED_FRAME(), Qenvironment, Vprocess_environment);
}
}
DEFVAR_LISP ("doc-directory", &Vdoc_directory,
doc: /* Directory containing the DOC file that comes with GNU Emacs.
-This is usually the same as data-directory. */);
+This is usually the same as `data-directory'. */);
DEFVAR_LISP ("configure-info-directory", &Vconfigure_info_directory,
doc: /* For internal use by the build procedure only.
This is the name of the directory in which the build procedure installed
-Emacs's info files; the default value for Info-default-directory-list
+Emacs's info files; the default value for `Info-default-directory-list'
includes this. */);
Vconfigure_info_directory = build_string (PATH_INFO);