aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c95
1 files changed, 43 insertions, 52 deletions
diff --git a/src/process.c b/src/process.c
index 53cc42f223e..4f103752296 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1878,13 +1878,7 @@ create_process (process, new_argv, current_dir)
1878#ifdef AIX 1878#ifdef AIX
1879 struct sigaction sighup_action; 1879 struct sigaction sighup_action;
1880#endif 1880#endif
1881#else /* !POSIX_SIGNALS */ 1881#endif /* POSIX_SIGNALS */
1882#if 0
1883#ifdef SIGCHLD
1884 SIGTYPE (*sigchld)();
1885#endif
1886#endif /* 0 */
1887#endif /* !POSIX_SIGNALS */
1888 /* Use volatile to protect variables from being clobbered by longjmp. */ 1882 /* Use volatile to protect variables from being clobbered by longjmp. */
1889 volatile int forkin, forkout; 1883 volatile int forkin, forkout;
1890 volatile int pty_flag = 0; 1884 volatile int pty_flag = 0;
@@ -2008,14 +2002,9 @@ create_process (process, new_argv, current_dir)
2008 sigprocmask (SIG_BLOCK, &blocked, &procmask); 2002 sigprocmask (SIG_BLOCK, &blocked, &procmask);
2009#else /* !POSIX_SIGNALS */ 2003#else /* !POSIX_SIGNALS */
2010#ifdef SIGCHLD 2004#ifdef SIGCHLD
2011#if defined (BSD_SYSTEM) || defined (HPUX) 2005#if defined (BSD_SYSTEM)
2012 sigsetmask (sigmask (SIGCHLD)); 2006 sigsetmask (sigmask (SIGCHLD));
2013#else /* ordinary USG */ 2007#endif /* BSD_SYSTEM */
2014#if 0
2015 sigchld_deferred = 0;
2016 sigchld = signal (SIGCHLD, create_process_sigchld);
2017#endif
2018#endif /* ordinary USG */
2019#endif /* SIGCHLD */ 2008#endif /* SIGCHLD */
2020#endif /* !POSIX_SIGNALS */ 2009#endif /* !POSIX_SIGNALS */
2021 2010
@@ -2172,13 +2161,9 @@ create_process (process, new_argv, current_dir)
2172 sigprocmask (SIG_SETMASK, &procmask, 0); 2161 sigprocmask (SIG_SETMASK, &procmask, 0);
2173#else /* !POSIX_SIGNALS */ 2162#else /* !POSIX_SIGNALS */
2174#ifdef SIGCHLD 2163#ifdef SIGCHLD
2175#if defined (BSD_SYSTEM) || defined (HPUX) 2164#if defined (BSD_SYSTEM)
2176 sigsetmask (SIGEMPTYMASK); 2165 sigsetmask (SIGEMPTYMASK);
2177#else /* ordinary USG */ 2166#endif /* BSD_SYSTEM */
2178#if 0
2179 signal (SIGCHLD, sigchld);
2180#endif
2181#endif /* ordinary USG */
2182#endif /* SIGCHLD */ 2167#endif /* SIGCHLD */
2183#endif /* !POSIX_SIGNALS */ 2168#endif /* !POSIX_SIGNALS */
2184 2169
@@ -2275,17 +2260,9 @@ create_process (process, new_argv, current_dir)
2275 sigprocmask (SIG_SETMASK, &procmask, 0); 2260 sigprocmask (SIG_SETMASK, &procmask, 0);
2276#else /* !POSIX_SIGNALS */ 2261#else /* !POSIX_SIGNALS */
2277#ifdef SIGCHLD 2262#ifdef SIGCHLD
2278#if defined (BSD_SYSTEM) || defined (HPUX) 2263#if defined (BSD_SYSTEM)
2279 sigsetmask (SIGEMPTYMASK); 2264 sigsetmask (SIGEMPTYMASK);
2280#else /* ordinary USG */ 2265#endif /* BSD_SYSTEM */
2281#if 0
2282 signal (SIGCHLD, sigchld);
2283 /* Now really handle any of these signals
2284 that came in during this function. */
2285 if (sigchld_deferred)
2286 kill (getpid (), SIGCHLD);
2287#endif
2288#endif /* ordinary USG */
2289#endif /* SIGCHLD */ 2266#endif /* SIGCHLD */
2290#endif /* !POSIX_SIGNALS */ 2267#endif /* !POSIX_SIGNALS */
2291 2268
@@ -3640,23 +3617,9 @@ usage: (make-network-process &rest ARGS) */)
3640 immediate_quit = 1; 3617 immediate_quit = 1;
3641 QUIT; 3618 QUIT;
3642 3619
3643 /* This turns off all alarm-based interrupts; the
3644 bind_polling_period call above doesn't always turn all the
3645 short-interval ones off, especially if interrupt_input is
3646 set.
3647
3648 It'd be nice to be able to control the connect timeout
3649 though. Would non-blocking connect calls be portable?
3650
3651 This used to be conditioned by HAVE_GETADDRINFO. Why? */
3652
3653 turn_on_atimers (0);
3654
3655 ret = connect (s, lres->ai_addr, lres->ai_addrlen); 3620 ret = connect (s, lres->ai_addr, lres->ai_addrlen);
3656 xerrno = errno; 3621 xerrno = errno;
3657 3622
3658 turn_on_atimers (1);
3659
3660 if (ret == 0 || xerrno == EISCONN) 3623 if (ret == 0 || xerrno == EISCONN)
3661 { 3624 {
3662 /* The unwind-protect will be discarded afterwards. 3625 /* The unwind-protect will be discarded afterwards.
@@ -3676,6 +3639,40 @@ usage: (make-network-process &rest ARGS) */)
3676#endif 3639#endif
3677#endif 3640#endif
3678 3641
3642#ifndef WINDOWSNT
3643 if (xerrno == EINTR)
3644 {
3645 /* Unlike most other syscalls connect() cannot be called
3646 again. (That would return EALREADY.) The proper way to
3647 wait for completion is select(). */
3648 int sc, len;
3649 SELECT_TYPE fdset;
3650 retry_select:
3651 FD_ZERO (&fdset);
3652 FD_SET (s, &fdset);
3653 QUIT;
3654 sc = select (s + 1, (SELECT_TYPE *)0, &fdset, (SELECT_TYPE *)0,
3655 (EMACS_TIME *)0);
3656 if (sc == -1)
3657 {
3658 if (errno == EINTR)
3659 goto retry_select;
3660 else
3661 report_file_error ("select failed", Qnil);
3662 }
3663 eassert (sc > 0);
3664
3665 len = sizeof xerrno;
3666 eassert (FD_ISSET (s, &fdset));
3667 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1)
3668 report_file_error ("getsockopt failed", Qnil);
3669 if (xerrno)
3670 errno = xerrno, report_file_error ("error during connect", Qnil);
3671 else
3672 break;
3673 }
3674#endif /* !WINDOWSNT */
3675
3679 immediate_quit = 0; 3676 immediate_quit = 0;
3680 3677
3681 /* Discard the unwind protect closing S. */ 3678 /* Discard the unwind protect closing S. */
@@ -3683,8 +3680,10 @@ usage: (make-network-process &rest ARGS) */)
3683 emacs_close (s); 3680 emacs_close (s);
3684 s = -1; 3681 s = -1;
3685 3682
3683#ifdef WINDOWSNT
3686 if (xerrno == EINTR) 3684 if (xerrno == EINTR)
3687 goto retry_connect; 3685 goto retry_connect;
3686#endif
3688 } 3687 }
3689 3688
3690 if (s >= 0) 3689 if (s >= 0)
@@ -6704,11 +6703,6 @@ sigchld_handler (signo)
6704 /* PID == 0 means no processes found, PID == -1 means a real 6703 /* PID == 0 means no processes found, PID == -1 means a real
6705 failure. We have done all our job, so return. */ 6704 failure. We have done all our job, so return. */
6706 6705
6707 /* USG systems forget handlers when they are used;
6708 must reestablish each time */
6709#if defined (USG) && !defined (POSIX_SIGNALS)
6710 signal (signo, sigchld_handler); /* WARNING - must come after wait3() */
6711#endif
6712 errno = old_errno; 6706 errno = old_errno;
6713 return; 6707 return;
6714 } 6708 }
@@ -6809,9 +6803,6 @@ sigchld_handler (signo)
6809#if (defined WINDOWSNT \ 6803#if (defined WINDOWSNT \
6810 || (defined USG && !defined GNU_LINUX \ 6804 || (defined USG && !defined GNU_LINUX \
6811 && !(defined HPUX && defined WNOHANG))) 6805 && !(defined HPUX && defined WNOHANG)))
6812#if defined (USG) && ! defined (POSIX_SIGNALS)
6813 signal (signo, sigchld_handler);
6814#endif
6815 errno = old_errno; 6806 errno = old_errno;
6816 return; 6807 return;
6817#endif /* USG, but not HPUX with WNOHANG */ 6808#endif /* USG, but not HPUX with WNOHANG */