From: Philipp Stephani Date: Wed, 23 Dec 2020 15:26:57 +0000 (+0100) Subject: Pass C string pointer to current directory to 'child_setup'. X-Git-Tag: emacs-28.0.90~4599 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bdcea81a2f906be3c573c42276dbfd35ccb432f9;p=emacs.git Pass C string pointer to current directory to 'child_setup'. This avoids the impression that 'child_setup' could do anything Lisp-related. * src/callproc.c (child_setup): Pass C pointer to current directory name. (call_process): Adapt callers. * src/process.c (create_process): Adapt callers. --- diff --git a/src/callproc.c b/src/callproc.c index 93a8bb86417..bd8442ce2b9 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -544,8 +544,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, char *const *env = make_environment_block (current_dir); #ifdef MSDOS /* MW, July 1993 */ - status - = child_setup (filefd, fd_output, fd_error, new_argv, env, current_dir); + status = child_setup (filefd, fd_output, fd_error, new_argv, env, + SSDATA (current_dir)); if (status < 0) { @@ -592,7 +592,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, block_child_signal (&oldset); #ifdef WINDOWSNT - pid = child_setup (filefd, fd_output, fd_error, new_argv, env, current_dir); + pid = child_setup (filefd, fd_output, fd_error, new_argv, env, + SSDATA (current_dir)); #else /* not WINDOWSNT */ /* vfork, and prevent local vars from being clobbered by the vfork. */ @@ -651,7 +652,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, signal (SIGPROF, SIG_DFL); #endif - child_setup (filefd, fd_output, fd_error, new_argv, env, current_dir); + child_setup (filefd, fd_output, fd_error, new_argv, env, + SSDATA (current_dir)); } #endif /* not WINDOWSNT */ @@ -1221,7 +1223,7 @@ exec_failed (char const *name, int err) CHILD_SETUP_TYPE child_setup (int in, int out, int err, char **new_argv, char *const *env, - Lisp_Object current_dir) + const char *current_dir) { #ifdef WINDOWSNT int cpid; @@ -1243,13 +1245,13 @@ child_setup (int in, int out, int err, char **new_argv, char *const *env, should only return an error if the directory's permissions are changed between the check and this chdir, but we should at least check. */ - if (chdir (SSDATA (current_dir)) < 0) + if (chdir (current_dir) < 0) _exit (EXIT_CANCELED); #endif #ifdef WINDOWSNT prepare_standard_handles (in, out, err, handles); - set_process_dir (SSDATA (current_dir)); + set_process_dir (current_dir); /* Spawn the child. (See w32proc.c:sys_spawnve). */ cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env); reset_standard_handles (in, out, err, handles); diff --git a/src/lisp.h b/src/lisp.h index d20e69ff896..07ba2bcbbaf 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4501,7 +4501,7 @@ extern void setup_process_coding_systems (Lisp_Object); #endif extern CHILD_SETUP_TYPE child_setup (int, int, int, char **, char *const *, - Lisp_Object); + const char *); extern char *const *make_environment_block (Lisp_Object); extern void init_callproc_1 (void); extern void init_callproc (void); diff --git a/src/process.c b/src/process.c index c579078c1ca..15b4a23784e 100644 --- a/src/process.c +++ b/src/process.c @@ -2259,9 +2259,11 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) if (forkerr < 0) forkerr = forkout; #ifdef WINDOWSNT - pid = child_setup (forkin, forkout, forkerr, new_argv, env, current_dir); + pid = child_setup (forkin, forkout, forkerr, new_argv, env, + SSDATA (current_dir)); #else /* not WINDOWSNT */ - child_setup (forkin, forkout, forkerr, new_argv, env, current_dir); + child_setup (forkin, forkout, forkerr, new_argv, env, + SSDATA (current_dir)); #endif /* not WINDOWSNT */ }