summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-07-19 19:34:17 +0000
committerRichard M. Stallman <rms@gnu.org>1994-07-19 19:34:17 +0000
commitefa04277fd3b434b668d1d4936cc5d0bac872da3 (patch)
tree597a421e583d72801c6d50b66fbcbd002fcda220
parented80e1ca508aa1ed6a7a0cbd7afed36510519c21 (diff)
downloademacs-efa04277fd3b434b668d1d4936cc5d0bac872da3.tar.gz
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
(sys_subshell): Expand ~ in dir. Do the processing of dir before calling fork. Use vfork.
-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 ()
int st;
char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS. */
#endif
- int pid = fork ();
+ int pid;
struct save_signal saved_handlers[5];
+ Lisp_Object dir;
+ unsigned char *str = 0;
+ int len;
saved_handlers[0].code = SIGINT;
saved_handlers[1].code = SIGQUIT;
@@ -656,6 +659,27 @@ sys_subshell ()
saved_handlers[3].code = 0;
#endif
+ /* Mentioning current_buffer->buffer would mean including buffer.h,
+ which somehow wedges the hp compiler. So instead... */
+
+ dir = intern ("default-directory");
+ /* Can't use NILP */
+ if (XFASTINT (Fboundp (dir)) == XFASTINT (Qnil))
+ goto xyzzy;
+ dir = Fsymbol_value (dir);
+ if (XTYPE (dir) != Lisp_String)
+ goto xyzzy;
+
+ dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil);
+ str = (unsigned char *) alloca (XSTRING (dir)->size + 2);
+ len = XSTRING (dir)->size;
+ bcopy (XSTRING (dir)->data, str, len);
+ if (str[len - 1] != '/') str[len++] = '/';
+ str[len] = 0;
+ xyzzy:
+
+ pid = vfork ();
+
if (pid == -1)
error ("Can't spawn subshell");
if (pid == 0)
@@ -670,30 +694,9 @@ sys_subshell ()
sh = "sh";
/* Use our buffer's default directory for the subshell. */
- {
- Lisp_Object dir;
- unsigned char *str;
- int len;
-
- /* mentioning current_buffer->buffer would mean including buffer.h,
- which somehow wedges the hp compiler. So instead... */
-
- dir = intern ("default-directory");
- /* Can't use NILP */
- if (XFASTINT (Fboundp (dir)) == XFASTINT (Qnil))
- goto xyzzy;
- dir = Fsymbol_value (dir);
- if (XTYPE (dir) != Lisp_String)
- goto xyzzy;
-
- str = (unsigned char *) alloca (XSTRING (dir)->size + 2);
- len = XSTRING (dir)->size;
- bcopy (XSTRING (dir)->data, str, len);
- if (str[len - 1] != '/') str[len++] = '/';
- str[len] = 0;
+ if (str)
chdir (str);
- }
- xyzzy:
+
#ifdef subprocesses
close_process_descs (); /* Close Emacs's pipes/ptys */
#endif
@@ -2033,7 +2036,17 @@ init_system_name ()
if (initialized)
#endif /* not CANNOT_DUMP */
{
- struct hostent *hp = gethostbyname (hostname);
+ struct hostent *hp;
+ int count;
+ for (count = 0; count < 10; count++)
+ {
+ hp = gethostbyname (hostname);
+#ifdef TRY_AGAIN
+ if (! (hp == 0 && h_errno == TRY_AGAIN))
+#endif
+ break;
+ Fsleep_for (make_number (1), Qnil);
+ }
if (hp)
{
char *fqdn = hp->h_name;