aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-07-19 19:34:17 +0000
committerRichard M. Stallman1994-07-19 19:34:17 +0000
commitefa04277fd3b434b668d1d4936cc5d0bac872da3 (patch)
tree597a421e583d72801c6d50b66fbcbd002fcda220 /src
parented80e1ca508aa1ed6a7a0cbd7afed36510519c21 (diff)
downloademacs-efa04277fd3b434b668d1d4936cc5d0bac872da3.tar.gz
emacs-efa04277fd3b434b668d1d4936cc5d0bac872da3.zip
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
(sys_subshell): Expand ~ in dir. Do the processing of dir before calling fork. Use vfork.
Diffstat (limited to 'src')
-rw-r--r--src/sysdep.c63
1 files changed, 38 insertions, 25 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index a88c7ec0174..0bb7b14826a 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -643,8 +643,11 @@ sys_subshell ()
643 int st; 643 int st;
644 char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS. */ 644 char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS. */
645#endif 645#endif
646 int pid = fork (); 646 int pid;
647 struct save_signal saved_handlers[5]; 647 struct save_signal saved_handlers[5];
648 Lisp_Object dir;
649 unsigned char *str = 0;
650 int len;
648 651
649 saved_handlers[0].code = SIGINT; 652 saved_handlers[0].code = SIGINT;
650 saved_handlers[1].code = SIGQUIT; 653 saved_handlers[1].code = SIGQUIT;
@@ -656,6 +659,27 @@ sys_subshell ()
656 saved_handlers[3].code = 0; 659 saved_handlers[3].code = 0;
657#endif 660#endif
658 661
662 /* Mentioning current_buffer->buffer would mean including buffer.h,
663 which somehow wedges the hp compiler. So instead... */
664
665 dir = intern ("default-directory");
666 /* Can't use NILP */
667 if (XFASTINT (Fboundp (dir)) == XFASTINT (Qnil))
668 goto xyzzy;
669 dir = Fsymbol_value (dir);
670 if (XTYPE (dir) != Lisp_String)
671 goto xyzzy;
672
673 dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil);
674 str = (unsigned char *) alloca (XSTRING (dir)->size + 2);
675 len = XSTRING (dir)->size;
676 bcopy (XSTRING (dir)->data, str, len);
677 if (str[len - 1] != '/') str[len++] = '/';
678 str[len] = 0;
679 xyzzy:
680
681 pid = vfork ();
682
659 if (pid == -1) 683 if (pid == -1)
660 error ("Can't spawn subshell"); 684 error ("Can't spawn subshell");
661 if (pid == 0) 685 if (pid == 0)
@@ -670,30 +694,9 @@ sys_subshell ()
670 sh = "sh"; 694 sh = "sh";
671 695
672 /* Use our buffer's default directory for the subshell. */ 696 /* Use our buffer's default directory for the subshell. */
673 { 697 if (str)
674 Lisp_Object dir;
675 unsigned char *str;
676 int len;
677
678 /* mentioning current_buffer->buffer would mean including buffer.h,
679 which somehow wedges the hp compiler. So instead... */
680
681 dir = intern ("default-directory");
682 /* Can't use NILP */
683 if (XFASTINT (Fboundp (dir)) == XFASTINT (Qnil))
684 goto xyzzy;
685 dir = Fsymbol_value (dir);
686 if (XTYPE (dir) != Lisp_String)
687 goto xyzzy;
688
689 str = (unsigned char *) alloca (XSTRING (dir)->size + 2);
690 len = XSTRING (dir)->size;
691 bcopy (XSTRING (dir)->data, str, len);
692 if (str[len - 1] != '/') str[len++] = '/';
693 str[len] = 0;
694 chdir (str); 698 chdir (str);
695 } 699
696 xyzzy:
697#ifdef subprocesses 700#ifdef subprocesses
698 close_process_descs (); /* Close Emacs's pipes/ptys */ 701 close_process_descs (); /* Close Emacs's pipes/ptys */
699#endif 702#endif
@@ -2033,7 +2036,17 @@ init_system_name ()
2033 if (initialized) 2036 if (initialized)
2034#endif /* not CANNOT_DUMP */ 2037#endif /* not CANNOT_DUMP */
2035 { 2038 {
2036 struct hostent *hp = gethostbyname (hostname); 2039 struct hostent *hp;
2040 int count;
2041 for (count = 0; count < 10; count++)
2042 {
2043 hp = gethostbyname (hostname);
2044#ifdef TRY_AGAIN
2045 if (! (hp == 0 && h_errno == TRY_AGAIN))
2046#endif
2047 break;
2048 Fsleep_for (make_number (1), Qnil);
2049 }
2037 if (hp) 2050 if (hp)
2038 { 2051 {
2039 char *fqdn = hp->h_name; 2052 char *fqdn = hp->h_name;