diff options
| author | Philipp Stephani | 2020-12-23 16:26:57 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2020-12-23 16:26:57 +0100 |
| commit | bdcea81a2f906be3c573c42276dbfd35ccb432f9 (patch) | |
| tree | 8780559b57846364b004aa4eadd75eecfd791f68 /src | |
| parent | 95334ee79ab60c0910a5528e586a24d11f91743b (diff) | |
| download | emacs-bdcea81a2f906be3c573c42276dbfd35ccb432f9.tar.gz emacs-bdcea81a2f906be3c573c42276dbfd35ccb432f9.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/callproc.c | 16 | ||||
| -rw-r--r-- | src/lisp.h | 2 | ||||
| -rw-r--r-- | src/process.c | 6 |
3 files changed, 14 insertions, 10 deletions
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, | |||
| 544 | char *const *env = make_environment_block (current_dir); | 544 | char *const *env = make_environment_block (current_dir); |
| 545 | 545 | ||
| 546 | #ifdef MSDOS /* MW, July 1993 */ | 546 | #ifdef MSDOS /* MW, July 1993 */ |
| 547 | status | 547 | status = child_setup (filefd, fd_output, fd_error, new_argv, env, |
| 548 | = child_setup (filefd, fd_output, fd_error, new_argv, env, current_dir); | 548 | SSDATA (current_dir)); |
| 549 | 549 | ||
| 550 | if (status < 0) | 550 | if (status < 0) |
| 551 | { | 551 | { |
| @@ -592,7 +592,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 592 | block_child_signal (&oldset); | 592 | block_child_signal (&oldset); |
| 593 | 593 | ||
| 594 | #ifdef WINDOWSNT | 594 | #ifdef WINDOWSNT |
| 595 | pid = child_setup (filefd, fd_output, fd_error, new_argv, env, current_dir); | 595 | pid = child_setup (filefd, fd_output, fd_error, new_argv, env, |
| 596 | SSDATA (current_dir)); | ||
| 596 | #else /* not WINDOWSNT */ | 597 | #else /* not WINDOWSNT */ |
| 597 | 598 | ||
| 598 | /* vfork, and prevent local vars from being clobbered by the vfork. */ | 599 | /* 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, | |||
| 651 | signal (SIGPROF, SIG_DFL); | 652 | signal (SIGPROF, SIG_DFL); |
| 652 | #endif | 653 | #endif |
| 653 | 654 | ||
| 654 | child_setup (filefd, fd_output, fd_error, new_argv, env, current_dir); | 655 | child_setup (filefd, fd_output, fd_error, new_argv, env, |
| 656 | SSDATA (current_dir)); | ||
| 655 | } | 657 | } |
| 656 | 658 | ||
| 657 | #endif /* not WINDOWSNT */ | 659 | #endif /* not WINDOWSNT */ |
| @@ -1221,7 +1223,7 @@ exec_failed (char const *name, int err) | |||
| 1221 | 1223 | ||
| 1222 | CHILD_SETUP_TYPE | 1224 | CHILD_SETUP_TYPE |
| 1223 | child_setup (int in, int out, int err, char **new_argv, char *const *env, | 1225 | child_setup (int in, int out, int err, char **new_argv, char *const *env, |
| 1224 | Lisp_Object current_dir) | 1226 | const char *current_dir) |
| 1225 | { | 1227 | { |
| 1226 | #ifdef WINDOWSNT | 1228 | #ifdef WINDOWSNT |
| 1227 | int cpid; | 1229 | int cpid; |
| @@ -1243,13 +1245,13 @@ child_setup (int in, int out, int err, char **new_argv, char *const *env, | |||
| 1243 | should only return an error if the directory's permissions | 1245 | should only return an error if the directory's permissions |
| 1244 | are changed between the check and this chdir, but we should | 1246 | are changed between the check and this chdir, but we should |
| 1245 | at least check. */ | 1247 | at least check. */ |
| 1246 | if (chdir (SSDATA (current_dir)) < 0) | 1248 | if (chdir (current_dir) < 0) |
| 1247 | _exit (EXIT_CANCELED); | 1249 | _exit (EXIT_CANCELED); |
| 1248 | #endif | 1250 | #endif |
| 1249 | 1251 | ||
| 1250 | #ifdef WINDOWSNT | 1252 | #ifdef WINDOWSNT |
| 1251 | prepare_standard_handles (in, out, err, handles); | 1253 | prepare_standard_handles (in, out, err, handles); |
| 1252 | set_process_dir (SSDATA (current_dir)); | 1254 | set_process_dir (current_dir); |
| 1253 | /* Spawn the child. (See w32proc.c:sys_spawnve). */ | 1255 | /* Spawn the child. (See w32proc.c:sys_spawnve). */ |
| 1254 | cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env); | 1256 | cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env); |
| 1255 | reset_standard_handles (in, out, err, handles); | 1257 | 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); | |||
| 4501 | #endif | 4501 | #endif |
| 4502 | 4502 | ||
| 4503 | extern CHILD_SETUP_TYPE child_setup (int, int, int, char **, char *const *, | 4503 | extern CHILD_SETUP_TYPE child_setup (int, int, int, char **, char *const *, |
| 4504 | Lisp_Object); | 4504 | const char *); |
| 4505 | extern char *const *make_environment_block (Lisp_Object); | 4505 | extern char *const *make_environment_block (Lisp_Object); |
| 4506 | extern void init_callproc_1 (void); | 4506 | extern void init_callproc_1 (void); |
| 4507 | extern void init_callproc (void); | 4507 | 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) | |||
| 2259 | if (forkerr < 0) | 2259 | if (forkerr < 0) |
| 2260 | forkerr = forkout; | 2260 | forkerr = forkout; |
| 2261 | #ifdef WINDOWSNT | 2261 | #ifdef WINDOWSNT |
| 2262 | pid = child_setup (forkin, forkout, forkerr, new_argv, env, current_dir); | 2262 | pid = child_setup (forkin, forkout, forkerr, new_argv, env, |
| 2263 | SSDATA (current_dir)); | ||
| 2263 | #else /* not WINDOWSNT */ | 2264 | #else /* not WINDOWSNT */ |
| 2264 | child_setup (forkin, forkout, forkerr, new_argv, env, current_dir); | 2265 | child_setup (forkin, forkout, forkerr, new_argv, env, |
| 2266 | SSDATA (current_dir)); | ||
| 2265 | #endif /* not WINDOWSNT */ | 2267 | #endif /* not WINDOWSNT */ |
| 2266 | } | 2268 | } |
| 2267 | 2269 | ||