diff options
| author | Paul Eggert | 2012-11-04 19:18:32 -0800 |
|---|---|---|
| committer | Paul Eggert | 2012-11-04 19:18:32 -0800 |
| commit | dd0333b6155c9c3aabdac9418c005e2e5b4796e7 (patch) | |
| tree | 6239cffc67b6a7b0e8eb594c22ed92a4cd28b2fc | |
| parent | 8148369cfba2c982a87fb4eb72d024e26e193a03 (diff) | |
| download | emacs-dd0333b6155c9c3aabdac9418c005e2e5b4796e7.tar.gz emacs-dd0333b6155c9c3aabdac9418c005e2e5b4796e7.zip | |
Assume at least POSIX.1-1988 for getpgrp, setpgid, setsid.
This removes code that has been obsolete since around 1990.
* admin/CPP-DEFINES (HAVE_SETPGID, HAVE_SETSID, SETPGRP_RELEASES_CTTY):
Remove; obsolete.
* configure.ac (setpgid, setsid): Assume their existence.
(AC_FUNC_GETPGRP, SETPGRP_RELEASES_CTTY): Remove; obsolete.
* src/callproc.c (Fcall_process):
* src/emacs.c (main):
* src/process.c (create_process):
* src/term.c (dissociate_if_controlling_tty):
Assume setsid exists.
* src/callproc.c (child_setup): Assume setpgid exists and behaves as
per POSIX.1-1988 or later.
* src/conf_post.h (setpgid) [!HAVE_SETPGID]: Remove.
* src/emacs.c (shut_down_emacs):
* src/sysdep.c (sys_suspend, init_foreground_group):
Assume getpgrp behaves as per POSIX.1-1998 or later.
* src/msdos.c (setpgrp): Remove.
(tcgetpgrp, setpgid, setsid): New functions.
* src/systty.h (EMACS_GETPGRP): Remove. All callers now use getpgrp.
* src/term.c (no_controlling_tty): Remove; unused.
* src/w32proc.c (setpgrp): Remove.
(setsid, tcgetpgrp): New functions.
Fixes: debbugs:12800
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | admin/CPP-DEFINES | 3 | ||||
| -rw-r--r-- | admin/ChangeLog | 4 | ||||
| -rw-r--r-- | configure.ac | 8 | ||||
| -rw-r--r-- | src/ChangeLog | 20 | ||||
| -rw-r--r-- | src/callproc.c | 10 | ||||
| -rw-r--r-- | src/conf_post.h | 8 | ||||
| -rw-r--r-- | src/emacs.c | 4 | ||||
| -rw-r--r-- | src/msdos.c | 4 | ||||
| -rw-r--r-- | src/process.c | 18 | ||||
| -rw-r--r-- | src/sysdep.c | 4 | ||||
| -rw-r--r-- | src/systty.h | 10 | ||||
| -rw-r--r-- | src/term.c | 35 | ||||
| -rw-r--r-- | src/w32proc.c | 14 |
14 files changed, 51 insertions, 95 deletions
| @@ -1,5 +1,9 @@ | |||
| 1 | 2012-11-05 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-11-05 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Assume at least POSIX.1-1988 for getpgrp, setpgid, setsid (Bug#12800). | ||
| 4 | * configure.ac (setpgid, setsid): Assume their existence. | ||
| 5 | (AC_FUNC_GETPGRP, SETPGRP_RELEASES_CTTY): Remove; obsolete. | ||
| 6 | |||
| 3 | Simplify by assuming __fpending. | 7 | Simplify by assuming __fpending. |
| 4 | Now that Emacs is using the gnulib fpending module, | 8 | Now that Emacs is using the gnulib fpending module, |
| 5 | there's no need for Emacs to have a separate implementation. | 9 | there's no need for Emacs to have a separate implementation. |
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index fb217fc22e6..0a4c14cb95c 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES | |||
| @@ -298,9 +298,7 @@ HAVE_SENDTO | |||
| 298 | HAVE_SEQPACKET | 298 | HAVE_SEQPACKET |
| 299 | HAVE_SETITIMER | 299 | HAVE_SETITIMER |
| 300 | HAVE_SETLOCALE | 300 | HAVE_SETLOCALE |
| 301 | HAVE_SETPGID | ||
| 302 | HAVE_SETRLIMIT | 301 | HAVE_SETRLIMIT |
| 303 | HAVE_SETSID | ||
| 304 | HAVE_SHARED_GAME_DIR | 302 | HAVE_SHARED_GAME_DIR |
| 305 | HAVE_SHUTDOWN | 303 | HAVE_SHUTDOWN |
| 306 | HAVE_SIGNED_${GLTYPE} | 304 | HAVE_SIGNED_${GLTYPE} |
| @@ -432,7 +430,6 @@ PTY_OPEN | |||
| 432 | PTY_TTY_NAME_SPRINTF | 430 | PTY_TTY_NAME_SPRINTF |
| 433 | PURESIZE | 431 | PURESIZE |
| 434 | RUN_TIME_REMAP | 432 | RUN_TIME_REMAP |
| 435 | SETPGRP_RELEASES_CTTY | ||
| 436 | SETUP_SLAVE_PTY | 433 | SETUP_SLAVE_PTY |
| 437 | SIGALRM | 434 | SIGALRM |
| 438 | SIGCHLD | 435 | SIGCHLD |
diff --git a/admin/ChangeLog b/admin/ChangeLog index c48faadab16..496e1c1bb6a 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2012-11-05 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-11-05 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Assume at least POSIX.1-1988 for getpgrp, setpgid, setsid (Bug#12800). | ||
| 4 | * CPP-DEFINES (HAVE_SETPGID, HAVE_SETSID, SETPGRP_RELEASES_CTTY): | ||
| 5 | Remove; obsolete. | ||
| 6 | |||
| 3 | Simplify by assuming __fpending. | 7 | Simplify by assuming __fpending. |
| 4 | * CPP-DEFINES (PENDING_OUTPUT_COUNT): Remove. | 8 | * CPP-DEFINES (PENDING_OUTPUT_COUNT): Remove. |
| 5 | 9 | ||
diff --git a/configure.ac b/configure.ac index 9a562a37a8d..9146c669096 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -2871,9 +2871,9 @@ AC_SUBST(BLESSMAIL_TARGET) | |||
| 2871 | 2871 | ||
| 2872 | AC_CHECK_FUNCS(gethostname \ | 2872 | AC_CHECK_FUNCS(gethostname \ |
| 2873 | closedir getrusage get_current_dir_name \ | 2873 | closedir getrusage get_current_dir_name \ |
| 2874 | lrand48 setsid \ | 2874 | lrand48 \ |
| 2875 | fpathconf select euidaccess getpagesize setlocale \ | 2875 | fpathconf select euidaccess getpagesize setlocale \ |
| 2876 | utimes getrlimit setrlimit setpgid getcwd shutdown getaddrinfo \ | 2876 | utimes getrlimit setrlimit getcwd shutdown getaddrinfo \ |
| 2877 | strsignal setitimer \ | 2877 | strsignal setitimer \ |
| 2878 | sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ | 2878 | sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ |
| 2879 | gai_strerror mkstemp getline getdelim fsync sync \ | 2879 | gai_strerror mkstemp getline getdelim fsync sync \ |
| @@ -2916,8 +2916,6 @@ AC_CHECK_HEADERS_ONCE(sys/un.h) | |||
| 2916 | 2916 | ||
| 2917 | AC_FUNC_FSEEKO | 2917 | AC_FUNC_FSEEKO |
| 2918 | 2918 | ||
| 2919 | AC_FUNC_GETPGRP | ||
| 2920 | |||
| 2921 | # UNIX98 PTYs. | 2919 | # UNIX98 PTYs. |
| 2922 | AC_CHECK_FUNCS(grantpt) | 2920 | AC_CHECK_FUNCS(grantpt) |
| 2923 | 2921 | ||
| @@ -3964,8 +3962,6 @@ case $opsys in | |||
| 3964 | irix6-5) | 3962 | irix6-5) |
| 3965 | AC_DEFINE(PREFER_VSUSP, 1, [Define if process_send_signal should | 3963 | AC_DEFINE(PREFER_VSUSP, 1, [Define if process_send_signal should |
| 3966 | use VSUSP instead of VSWTCH.]) | 3964 | use VSUSP instead of VSWTCH.]) |
| 3967 | AC_DEFINE(SETPGRP_RELEASES_CTTY, 1, [Define if process.c:child_setup | ||
| 3968 | should not call setpgrp.]) | ||
| 3969 | ;; | 3965 | ;; |
| 3970 | 3966 | ||
| 3971 | sol2-10) | 3967 | sol2-10) |
diff --git a/src/ChangeLog b/src/ChangeLog index 29efd9f181c..6c515271594 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,25 @@ | |||
| 1 | 2012-11-05 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-11-05 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Assume at least POSIX.1-1988 for getpgrp, setpgid, setsid (Bug#12800). | ||
| 4 | This removes code that has been obsolete since around 1990. | ||
| 5 | * callproc.c (Fcall_process): | ||
| 6 | * emacs.c (main): | ||
| 7 | * process.c (create_process): | ||
| 8 | * term.c (dissociate_if_controlling_tty): | ||
| 9 | Assume setsid exists. | ||
| 10 | * callproc.c (child_setup): Assume setpgid exists and behaves as | ||
| 11 | per POSIX.1-1988 or later. | ||
| 12 | * conf_post.h (setpgid) [!HAVE_SETPGID]: Remove. | ||
| 13 | * emacs.c (shut_down_emacs): | ||
| 14 | * sysdep.c (sys_suspend, init_foreground_group): | ||
| 15 | Assume getpgrp behaves as per POSIX.1-1998 or later. | ||
| 16 | * msdos.c (setpgrp): Remove. | ||
| 17 | (tcgetpgrp, setpgid, setsid): New functions. | ||
| 18 | * systty.h (EMACS_GETPGRP): Remove. All callers now use getpgrp. | ||
| 19 | * term.c (no_controlling_tty): Remove; unused. | ||
| 20 | * w32proc.c (setpgrp): Remove. | ||
| 21 | (setsid, tcgetpgrp): New functions. | ||
| 22 | |||
| 3 | Simplify by assuming __fpending. | 23 | Simplify by assuming __fpending. |
| 4 | * dispnew.c: Include <fpending.h>, not <stdio_ext.h>. | 24 | * dispnew.c: Include <fpending.h>, not <stdio_ext.h>. |
| 5 | (update_frame_1): Use __fpending, not PENDING_OUTPUT_COUNT. | 25 | (update_frame_1): Use __fpending, not PENDING_OUTPUT_COUNT. |
diff --git a/src/callproc.c b/src/callproc.c index c236f22fc86..c7bbe36e605 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -612,11 +612,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 612 | if (fd[0] >= 0) | 612 | if (fd[0] >= 0) |
| 613 | emacs_close (fd[0]); | 613 | emacs_close (fd[0]); |
| 614 | 614 | ||
| 615 | #ifdef HAVE_SETSID | ||
| 616 | setsid (); | 615 | setsid (); |
| 617 | #else | ||
| 618 | setpgid (0, 0); | ||
| 619 | #endif | ||
| 620 | 616 | ||
| 621 | /* Emacs ignores SIGPIPE, but the child should not. */ | 617 | /* Emacs ignores SIGPIPE, but the child should not. */ |
| 622 | signal (SIGPIPE, SIG_DFL); | 618 | signal (SIGPIPE, SIG_DFL); |
| @@ -1286,11 +1282,7 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp, | |||
| 1286 | if (err != in && err != out) | 1282 | if (err != in && err != out) |
| 1287 | emacs_close (err); | 1283 | emacs_close (err); |
| 1288 | 1284 | ||
| 1289 | #if defined HAVE_SETPGID || ! (defined USG && defined SETPGRP_RELEASES_CTTY) | 1285 | setpgid (0, 0); |
| 1290 | setpgid (pid, pid); | ||
| 1291 | #endif | ||
| 1292 | |||
| 1293 | /* setpgrp_of_tty is incorrect here; it uses input_fd. */ | ||
| 1294 | tcsetpgrp (0, pid); | 1286 | tcsetpgrp (0, pid); |
| 1295 | 1287 | ||
| 1296 | /* execvp does not accept an environment arg so the only way | 1288 | /* execvp does not accept an environment arg so the only way |
diff --git a/src/conf_post.h b/src/conf_post.h index da3c3bd58b0..66390ddf103 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -121,14 +121,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */ | |||
| 121 | 121 | ||
| 122 | #define emacs_raise(sig) msdos_fatal_signal (sig) | 122 | #define emacs_raise(sig) msdos_fatal_signal (sig) |
| 123 | 123 | ||
| 124 | #ifndef HAVE_SETPGID | ||
| 125 | # ifdef USG | ||
| 126 | # define setpgid(pid, pgid) setpgrp () | ||
| 127 | # else | ||
| 128 | # define setpgid(pid, pgid) setpgrp (pid, pgid) | ||
| 129 | # endif | ||
| 130 | #endif | ||
| 131 | |||
| 132 | /* Define one of these for easier conditionals. */ | 124 | /* Define one of these for easier conditionals. */ |
| 133 | #ifdef HAVE_X_WINDOWS | 125 | #ifdef HAVE_X_WINDOWS |
| 134 | /* We need a little extra space, see ../../lisp/loadup.el and the | 126 | /* We need a little extra space, see ../../lisp/loadup.el and the |
diff --git a/src/emacs.c b/src/emacs.c index 061c4b4b131..f12713b9628 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1101,9 +1101,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1101 | that it is not accessible to programs started from .emacs. */ | 1101 | that it is not accessible to programs started from .emacs. */ |
| 1102 | fcntl (daemon_pipe[1], F_SETFD, FD_CLOEXEC); | 1102 | fcntl (daemon_pipe[1], F_SETFD, FD_CLOEXEC); |
| 1103 | 1103 | ||
| 1104 | #ifdef HAVE_SETSID | ||
| 1105 | setsid (); | 1104 | setsid (); |
| 1106 | #endif | ||
| 1107 | #else /* DOS_NT */ | 1105 | #else /* DOS_NT */ |
| 1108 | fprintf (stderr, "This platform does not support the -daemon flag.\n"); | 1106 | fprintf (stderr, "This platform does not support the -daemon flag.\n"); |
| 1109 | exit (1); | 1107 | exit (1); |
| @@ -1915,7 +1913,7 @@ shut_down_emacs (int sig, Lisp_Object stuff) | |||
| 1915 | /* If we are controlling the terminal, reset terminal modes. */ | 1913 | /* If we are controlling the terminal, reset terminal modes. */ |
| 1916 | #ifndef DOS_NT | 1914 | #ifndef DOS_NT |
| 1917 | { | 1915 | { |
| 1918 | pid_t pgrp = EMACS_GETPGRP (0); | 1916 | pid_t pgrp = getpgrp (); |
| 1919 | pid_t tpgrp = tcgetpgrp (0); | 1917 | pid_t tpgrp = tcgetpgrp (0); |
| 1920 | if ((tpgrp != -1) && tpgrp == pgrp) | 1918 | if ((tpgrp != -1) && tpgrp == pgrp) |
| 1921 | { | 1919 | { |
diff --git a/src/msdos.c b/src/msdos.c index 79f0be48892..dd05a8b2c5d 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -3927,8 +3927,10 @@ croak (char *badfunc) | |||
| 3927 | /* | 3927 | /* |
| 3928 | * A few unimplemented functions that we silently ignore. | 3928 | * A few unimplemented functions that we silently ignore. |
| 3929 | */ | 3929 | */ |
| 3930 | int setpgrp (void) {return 0; } | 3930 | pid_t tcgetpgrp (int fd) { return 0; } |
| 3931 | int setpgid (int pid, int pgid) { return 0; } | ||
| 3931 | int setpriority (int x, int y, int z) { return 0; } | 3932 | int setpriority (int x, int y, int z) { return 0; } |
| 3933 | pid_t setsid (void) { return 0; } | ||
| 3932 | 3934 | ||
| 3933 | #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 | 3935 | #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 |
| 3934 | ssize_t | 3936 | ssize_t |
diff --git a/src/process.c b/src/process.c index 3c0e53f7784..16600f94ce4 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1739,7 +1739,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1739 | /* Make the pty be the controlling terminal of the process. */ | 1739 | /* Make the pty be the controlling terminal of the process. */ |
| 1740 | #ifdef HAVE_PTYS | 1740 | #ifdef HAVE_PTYS |
| 1741 | /* First, disconnect its current controlling terminal. */ | 1741 | /* First, disconnect its current controlling terminal. */ |
| 1742 | #ifdef HAVE_SETSID | ||
| 1743 | /* We tried doing setsid only if pty_flag, but it caused | 1742 | /* We tried doing setsid only if pty_flag, but it caused |
| 1744 | process_set_signal to fail on SGI when using a pipe. */ | 1743 | process_set_signal to fail on SGI when using a pipe. */ |
| 1745 | setsid (); | 1744 | setsid (); |
| @@ -1752,12 +1751,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1752 | ioctl (xforkin, TIOCSCTTY, 0); | 1751 | ioctl (xforkin, TIOCSCTTY, 0); |
| 1753 | #endif | 1752 | #endif |
| 1754 | } | 1753 | } |
| 1755 | #else /* not HAVE_SETSID */ | ||
| 1756 | /* It's very important to call setpgid here and no time | ||
| 1757 | afterwards. Otherwise, we lose our controlling tty which | ||
| 1758 | is set when we open the pty. */ | ||
| 1759 | setpgid (0, 0); | ||
| 1760 | #endif /* not HAVE_SETSID */ | ||
| 1761 | #if defined (LDISC1) | 1754 | #if defined (LDISC1) |
| 1762 | if (pty_flag && xforkin >= 0) | 1755 | if (pty_flag && xforkin >= 0) |
| 1763 | { | 1756 | { |
| @@ -1790,22 +1783,15 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1790 | ioctl (j, TIOCNOTTY, 0); | 1783 | ioctl (j, TIOCNOTTY, 0); |
| 1791 | emacs_close (j); | 1784 | emacs_close (j); |
| 1792 | } | 1785 | } |
| 1793 | #ifndef USG | ||
| 1794 | /* In order to get a controlling terminal on some versions | ||
| 1795 | of BSD, it is necessary to put the process in pgrp 0 | ||
| 1796 | before it opens the terminal. */ | ||
| 1797 | setpgid (0, 0); | ||
| 1798 | #endif | ||
| 1799 | } | 1786 | } |
| 1800 | #endif /* TIOCNOTTY */ | 1787 | #endif /* TIOCNOTTY */ |
| 1801 | 1788 | ||
| 1802 | #if !defined (DONT_REOPEN_PTY) | 1789 | #if !defined (DONT_REOPEN_PTY) |
| 1803 | /*** There is a suggestion that this ought to be a | 1790 | /*** There is a suggestion that this ought to be a |
| 1804 | conditional on TIOCSPGRP, | 1791 | conditional on TIOCSPGRP, or !defined TIOCSCTTY. |
| 1805 | or !(defined (HAVE_SETSID) && defined (TIOCSCTTY)). | ||
| 1806 | Trying the latter gave the wrong results on Debian GNU/Linux 1.1; | 1792 | Trying the latter gave the wrong results on Debian GNU/Linux 1.1; |
| 1807 | that system does seem to need this code, even though | 1793 | that system does seem to need this code, even though |
| 1808 | both HAVE_SETSID and TIOCSCTTY are defined. */ | 1794 | both TIOCSCTTY is defined. */ |
| 1809 | /* Now close the pty (if we had it open) and reopen it. | 1795 | /* Now close the pty (if we had it open) and reopen it. |
| 1810 | This makes the pty the controlling terminal of the subprocess. */ | 1796 | This makes the pty the controlling terminal of the subprocess. */ |
| 1811 | if (pty_flag) | 1797 | if (pty_flag) |
diff --git a/src/sysdep.c b/src/sysdep.c index 63eac5d9e09..aa9d0f38c3c 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -452,7 +452,7 @@ sys_suspend (void) | |||
| 452 | #if defined (SIGTSTP) && !defined (MSDOS) | 452 | #if defined (SIGTSTP) && !defined (MSDOS) |
| 453 | 453 | ||
| 454 | { | 454 | { |
| 455 | pid_t pgrp = EMACS_GETPGRP (0); | 455 | pid_t pgrp = getpgrp (); |
| 456 | EMACS_KILLPG (pgrp, SIGTSTP); | 456 | EMACS_KILLPG (pgrp, SIGTSTP); |
| 457 | } | 457 | } |
| 458 | 458 | ||
| @@ -709,7 +709,7 @@ static pid_t inherited_pgroup; | |||
| 709 | void | 709 | void |
| 710 | init_foreground_group (void) | 710 | init_foreground_group (void) |
| 711 | { | 711 | { |
| 712 | pid_t pgrp = EMACS_GETPGRP (0); | 712 | pid_t pgrp = getpgrp (); |
| 713 | inherited_pgroup = getpid () == pgrp ? 0 : pgrp; | 713 | inherited_pgroup = getpid () == pgrp ? 0 : pgrp; |
| 714 | } | 714 | } |
| 715 | 715 | ||
diff --git a/src/systty.h b/src/systty.h index 0611511d901..80bcaedf740 100644 --- a/src/systty.h +++ b/src/systty.h | |||
| @@ -52,16 +52,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 52 | #endif /* not CDEL */ | 52 | #endif /* not CDEL */ |
| 53 | #endif /* not _POSIX_VDISABLE */ | 53 | #endif /* not _POSIX_VDISABLE */ |
| 54 | 54 | ||
| 55 | /* Manipulate a terminal's current process group. */ | ||
| 56 | |||
| 57 | /* EMACS_GETPGRP (arg) returns the process group of the process. */ | ||
| 58 | |||
| 59 | #if defined (GETPGRP_VOID) | ||
| 60 | # define EMACS_GETPGRP(x) getpgrp() | ||
| 61 | #else /* !GETPGRP_VOID */ | ||
| 62 | # define EMACS_GETPGRP(x) getpgrp(x) | ||
| 63 | #endif /* !GETPGRP_VOID */ | ||
| 64 | |||
| 65 | /* Manipulate a TTY's input/output processing parameters. */ | 55 | /* Manipulate a TTY's input/output processing parameters. */ |
| 66 | 56 | ||
| 67 | /* struct emacs_tty is a structure used to hold the current tty | 57 | /* struct emacs_tty is a structure used to hold the current tty |
diff --git a/src/term.c b/src/term.c index ffc559469e6..578c701858f 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -133,10 +133,6 @@ enum no_color_bit | |||
| 133 | 133 | ||
| 134 | static int max_frame_cols; | 134 | static int max_frame_cols; |
| 135 | 135 | ||
| 136 | /* Non-zero if we have dropped our controlling tty and therefore | ||
| 137 | should not open a frame on stdout. */ | ||
| 138 | static int no_controlling_tty; | ||
| 139 | |||
| 140 | 136 | ||
| 141 | 137 | ||
| 142 | #ifdef HAVE_GPM | 138 | #ifdef HAVE_GPM |
| @@ -2918,36 +2914,9 @@ set_tty_hooks (struct terminal *terminal) | |||
| 2918 | static void | 2914 | static void |
| 2919 | dissociate_if_controlling_tty (int fd) | 2915 | dissociate_if_controlling_tty (int fd) |
| 2920 | { | 2916 | { |
| 2921 | #ifndef DOS_NT | ||
| 2922 | pid_t pgid = tcgetpgrp (fd); /* If tcgetpgrp succeeds, fd is the ctty. */ | 2917 | pid_t pgid = tcgetpgrp (fd); /* If tcgetpgrp succeeds, fd is the ctty. */ |
| 2923 | if (pgid != -1) | 2918 | if (0 <= pgid) |
| 2924 | { | 2919 | setsid (); |
| 2925 | #if defined (USG5) | ||
| 2926 | setpgrp (); | ||
| 2927 | no_controlling_tty = 1; | ||
| 2928 | #elif defined (CYGWIN) | ||
| 2929 | setsid (); | ||
| 2930 | no_controlling_tty = 1; | ||
| 2931 | #else | ||
| 2932 | #ifdef TIOCNOTTY /* Try BSD ioctls. */ | ||
| 2933 | sigset_t blocked; | ||
| 2934 | sigemptyset (&blocked); | ||
| 2935 | sigaddset (&blocked, SIGTTOU); | ||
| 2936 | pthread_sigmask (SIG_BLOCK, &blocked, 0); | ||
| 2937 | fd = emacs_open (DEV_TTY, O_RDWR, 0); | ||
| 2938 | if (fd != -1 && ioctl (fd, TIOCNOTTY, 0) != -1) | ||
| 2939 | { | ||
| 2940 | no_controlling_tty = 1; | ||
| 2941 | } | ||
| 2942 | if (fd != -1) | ||
| 2943 | emacs_close (fd); | ||
| 2944 | pthread_sigmask (SIG_UNBLOCK, &blocked, 0); | ||
| 2945 | #else | ||
| 2946 | # error "Unknown system." | ||
| 2947 | #endif /* ! TIOCNOTTY */ | ||
| 2948 | #endif /* ! USG */ | ||
| 2949 | } | ||
| 2950 | #endif /* !DOS_NT */ | ||
| 2951 | } | 2920 | } |
| 2952 | 2921 | ||
| 2953 | /* Create a termcap display on the tty device with the given name and | 2922 | /* Create a termcap display on the tty device with the given name and |
diff --git a/src/w32proc.c b/src/w32proc.c index adef7651b8c..f35a2da537c 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -230,14 +230,14 @@ sigismember (const sigset_t *set, int signo) | |||
| 230 | return (*set & (1U << signo)) != 0; | 230 | return (*set & (1U << signo)) != 0; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | int | 233 | pid_t |
| 234 | setpgrp (int pid, int gid) | 234 | getpgrp (void) |
| 235 | { | 235 | { |
| 236 | return 0; | 236 | return getpid (); |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | pid_t | 239 | pid_t |
| 240 | getpgrp (void) | 240 | tcgetpgrp (int fd) |
| 241 | { | 241 | { |
| 242 | return getpid (); | 242 | return getpid (); |
| 243 | } | 243 | } |
| @@ -248,6 +248,12 @@ setpgid (pid_t pid, pid_t pgid) | |||
| 248 | return 0; | 248 | return 0; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | pid_t | ||
| 252 | setsid (void) | ||
| 253 | { | ||
| 254 | return getpid (); | ||
| 255 | } | ||
| 256 | |||
| 251 | /* Emulations of interval timers. | 257 | /* Emulations of interval timers. |
| 252 | 258 | ||
| 253 | Limitations: only ITIMER_REAL and ITIMER_PROF are supported. | 259 | Limitations: only ITIMER_REAL and ITIMER_PROF are supported. |