aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorPaul Eggert2011-02-05 17:25:41 -0800
committerPaul Eggert2011-02-05 17:25:41 -0800
commit32299e33800dc6a78754b5ac2dc0e15caea93e48 (patch)
treefd0c9830df5c85736a2989464ad7a8d9f811bce1 /src/sysdep.c
parent7fbf7cae66482c80e93acb9864aad31cf29e5c83 (diff)
downloademacs-32299e33800dc6a78754b5ac2dc0e15caea93e48.tar.gz
emacs-32299e33800dc6a78754b5ac2dc0e15caea93e48.zip
don't ignore chdir failure
* sysdep.c (sys_subshell) [!defined DOS_NT]: Diagnose chdir failure and exit. (sys_subshell) [defined DOS_NT]: Mark with a FIXME the two remaining unchecked chdir calls in this function; some DOS/NT expert needs to fix them. * emacs.c (main): Mark with a FIXME the unchecked chdir calls in this function; some NextStep expert needs to fix them.
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 53b7f39171e..5760d0224eb 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -548,8 +548,13 @@ sys_subshell (void)
548 sh = "sh"; 548 sh = "sh";
549 549
550 /* Use our buffer's default directory for the subshell. */ 550 /* Use our buffer's default directory for the subshell. */
551 if (str) 551 if (str && chdir ((char *) str) != 0)
552 chdir ((char *) str); 552 {
553#ifndef DOS_NT
554 ignore_value (write (1, "Can't chdir\n", 12));
555 _exit (1);
556#endif
557 }
553 558
554 close_process_descs (); /* Close Emacs's pipes/ptys */ 559 close_process_descs (); /* Close Emacs's pipes/ptys */
555 560
@@ -567,7 +572,7 @@ sys_subshell (void)
567 setenv ("PWD", str, 1); 572 setenv ("PWD", str, 1);
568 } 573 }
569 st = system (sh); 574 st = system (sh);
570 chdir (oldwd); 575 chdir (oldwd); /* FIXME: Do the right thing on chdir failure. */
571 if (epwd) 576 if (epwd)
572 putenv (old_pwd); /* restore previous value */ 577 putenv (old_pwd); /* restore previous value */
573 } 578 }
@@ -575,7 +580,7 @@ sys_subshell (void)
575#ifdef WINDOWSNT 580#ifdef WINDOWSNT
576 /* Waits for process completion */ 581 /* Waits for process completion */
577 pid = _spawnlp (_P_WAIT, sh, sh, NULL); 582 pid = _spawnlp (_P_WAIT, sh, sh, NULL);
578 chdir (oldwd); 583 chdir (oldwd); /* FIXME: Do the right thing on chdir failure. */
579 if (pid == -1) 584 if (pid == -1)
580 write (1, "Can't execute subshell", 22); 585 write (1, "Can't execute subshell", 22);
581#else /* not WINDOWSNT */ 586#else /* not WINDOWSNT */