diff options
| author | Tom Tromey | 2013-08-25 14:25:59 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-08-25 14:25:59 -0600 |
| commit | 793ea5055aea85ff9227e1bf0c84ab37edba7201 (patch) | |
| tree | c9799eebe2b797a55fcbfcbd3710c9b5aa70051d /src/process.c | |
| parent | 1ce4c6398ea453a66f6943552b0ec866a690e9b1 (diff) | |
| parent | e687aa335a21662f67d2d73063272504a171ffab (diff) | |
| download | emacs-793ea5055aea85ff9227e1bf0c84ab37edba7201.tar.gz emacs-793ea5055aea85ff9227e1bf0c84ab37edba7201.zip | |
merge from trunk
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 72 |
1 files changed, 28 insertions, 44 deletions
diff --git a/src/process.c b/src/process.c index 1d1741d8b7e..3edc3b4f061 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -826,6 +826,15 @@ allocate_pty (char pty_name[PTY_NAME_SIZE]) | |||
| 826 | 826 | ||
| 827 | if (fd >= 0) | 827 | if (fd >= 0) |
| 828 | { | 828 | { |
| 829 | #ifdef PTY_OPEN | ||
| 830 | /* Set FD's close-on-exec flag. This is needed even if | ||
| 831 | PT_OPEN calls posix_openpt with O_CLOEXEC, since POSIX | ||
| 832 | doesn't require support for that combination. | ||
| 833 | Multithreaded platforms where posix_openpt ignores | ||
| 834 | O_CLOEXEC (or where PTY_OPEN doesn't call posix_openpt) | ||
| 835 | have a race condition between the PTY_OPEN and here. */ | ||
| 836 | fcntl (fd, F_SETFD, FD_CLOEXEC); | ||
| 837 | #endif | ||
| 829 | /* check to make certain that both sides are available | 838 | /* check to make certain that both sides are available |
| 830 | this avoids a nasty yet stupid bug in rlogins */ | 839 | this avoids a nasty yet stupid bug in rlogins */ |
| 831 | #ifdef PTY_TTY_NAME_SPRINTF | 840 | #ifdef PTY_TTY_NAME_SPRINTF |
| @@ -1322,15 +1331,18 @@ DEFUN ("process-thread", Fprocess_thread, Sprocess_thread, | |||
| 1322 | DEFUN ("set-process-window-size", Fset_process_window_size, | 1331 | DEFUN ("set-process-window-size", Fset_process_window_size, |
| 1323 | Sset_process_window_size, 3, 3, 0, | 1332 | Sset_process_window_size, 3, 3, 0, |
| 1324 | doc: /* Tell PROCESS that it has logical window size HEIGHT and WIDTH. */) | 1333 | doc: /* Tell PROCESS that it has logical window size HEIGHT and WIDTH. */) |
| 1325 | (register Lisp_Object process, Lisp_Object height, Lisp_Object width) | 1334 | (Lisp_Object process, Lisp_Object height, Lisp_Object width) |
| 1326 | { | 1335 | { |
| 1327 | CHECK_PROCESS (process); | 1336 | CHECK_PROCESS (process); |
| 1328 | CHECK_RANGED_INTEGER (height, 0, INT_MAX); | 1337 | |
| 1329 | CHECK_RANGED_INTEGER (width, 0, INT_MAX); | 1338 | /* All known platforms store window sizes as 'unsigned short'. */ |
| 1339 | CHECK_RANGED_INTEGER (height, 0, USHRT_MAX); | ||
| 1340 | CHECK_RANGED_INTEGER (width, 0, USHRT_MAX); | ||
| 1330 | 1341 | ||
| 1331 | if (XPROCESS (process)->infd < 0 | 1342 | if (XPROCESS (process)->infd < 0 |
| 1332 | || set_window_size (XPROCESS (process)->infd, | 1343 | || (set_window_size (XPROCESS (process)->infd, |
| 1333 | XINT (height), XINT (width)) <= 0) | 1344 | XINT (height), XINT (width)) |
| 1345 | < 0)) | ||
| 1334 | return Qnil; | 1346 | return Qnil; |
| 1335 | else | 1347 | else |
| 1336 | return Qt; | 1348 | return Qt; |
| @@ -1590,22 +1602,9 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) | |||
| 1590 | function. The argument list is protected by the caller, so all | 1602 | function. The argument list is protected by the caller, so all |
| 1591 | we really have to worry about is buffer. */ | 1603 | we really have to worry about is buffer. */ |
| 1592 | { | 1604 | { |
| 1593 | struct gcpro gcpro1, gcpro2; | 1605 | struct gcpro gcpro1; |
| 1594 | 1606 | GCPRO1 (buffer); | |
| 1595 | current_dir = BVAR (current_buffer, directory); | 1607 | current_dir = encode_current_directory (); |
| 1596 | |||
| 1597 | GCPRO2 (buffer, current_dir); | ||
| 1598 | |||
| 1599 | current_dir = Funhandled_file_name_directory (current_dir); | ||
| 1600 | if (NILP (current_dir)) | ||
| 1601 | /* If the file name handler says that current_dir is unreachable, use | ||
| 1602 | a sensible default. */ | ||
| 1603 | current_dir = build_string ("~/"); | ||
| 1604 | current_dir = expand_and_dir_to_file (current_dir, Qnil); | ||
| 1605 | if (NILP (Ffile_accessible_directory_p (current_dir))) | ||
| 1606 | report_file_error ("Setting current directory", | ||
| 1607 | BVAR (current_buffer, directory)); | ||
| 1608 | |||
| 1609 | UNGCPRO; | 1608 | UNGCPRO; |
| 1610 | } | 1609 | } |
| 1611 | 1610 | ||
| @@ -1852,7 +1851,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1852 | bool pty_flag = 0; | 1851 | bool pty_flag = 0; |
| 1853 | char pty_name[PTY_NAME_SIZE]; | 1852 | char pty_name[PTY_NAME_SIZE]; |
| 1854 | Lisp_Object lisp_pty_name = Qnil; | 1853 | Lisp_Object lisp_pty_name = Qnil; |
| 1855 | Lisp_Object encoded_current_dir; | ||
| 1856 | 1854 | ||
| 1857 | inchannel = outchannel = -1; | 1855 | inchannel = outchannel = -1; |
| 1858 | 1856 | ||
| @@ -1914,15 +1912,13 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1914 | /* This may signal an error. */ | 1912 | /* This may signal an error. */ |
| 1915 | setup_process_coding_systems (process); | 1913 | setup_process_coding_systems (process); |
| 1916 | 1914 | ||
| 1917 | encoded_current_dir = ENCODE_FILE (current_dir); | ||
| 1918 | |||
| 1919 | block_input (); | 1915 | block_input (); |
| 1920 | block_child_signal (); | 1916 | block_child_signal (); |
| 1921 | 1917 | ||
| 1922 | #ifndef WINDOWSNT | 1918 | #ifndef WINDOWSNT |
| 1923 | /* vfork, and prevent local vars from being clobbered by the vfork. */ | 1919 | /* vfork, and prevent local vars from being clobbered by the vfork. */ |
| 1924 | { | 1920 | { |
| 1925 | Lisp_Object volatile encoded_current_dir_volatile = encoded_current_dir; | 1921 | Lisp_Object volatile current_dir_volatile = current_dir; |
| 1926 | Lisp_Object volatile lisp_pty_name_volatile = lisp_pty_name; | 1922 | Lisp_Object volatile lisp_pty_name_volatile = lisp_pty_name; |
| 1927 | char **volatile new_argv_volatile = new_argv; | 1923 | char **volatile new_argv_volatile = new_argv; |
| 1928 | int volatile forkin_volatile = forkin; | 1924 | int volatile forkin_volatile = forkin; |
| @@ -1931,7 +1927,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1931 | 1927 | ||
| 1932 | pid = vfork (); | 1928 | pid = vfork (); |
| 1933 | 1929 | ||
| 1934 | encoded_current_dir = encoded_current_dir_volatile; | 1930 | current_dir = current_dir_volatile; |
| 1935 | lisp_pty_name = lisp_pty_name_volatile; | 1931 | lisp_pty_name = lisp_pty_name_volatile; |
| 1936 | new_argv = new_argv_volatile; | 1932 | new_argv = new_argv_volatile; |
| 1937 | forkin = forkin_volatile; | 1933 | forkin = forkin_volatile; |
| @@ -2043,11 +2039,9 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 2043 | if (pty_flag) | 2039 | if (pty_flag) |
| 2044 | child_setup_tty (xforkout); | 2040 | child_setup_tty (xforkout); |
| 2045 | #ifdef WINDOWSNT | 2041 | #ifdef WINDOWSNT |
| 2046 | pid = child_setup (xforkin, xforkout, xforkout, | 2042 | pid = child_setup (xforkin, xforkout, xforkout, new_argv, 1, current_dir); |
| 2047 | new_argv, 1, encoded_current_dir); | ||
| 2048 | #else /* not WINDOWSNT */ | 2043 | #else /* not WINDOWSNT */ |
| 2049 | child_setup (xforkin, xforkout, xforkout, | 2044 | child_setup (xforkin, xforkout, xforkout, new_argv, 1, current_dir); |
| 2050 | new_argv, 1, encoded_current_dir); | ||
| 2051 | #endif /* not WINDOWSNT */ | 2045 | #endif /* not WINDOWSNT */ |
| 2052 | } | 2046 | } |
| 2053 | 2047 | ||
| @@ -4012,15 +4006,12 @@ deactivate_process (Lisp_Object proc) | |||
| 4012 | } | 4006 | } |
| 4013 | #endif | 4007 | #endif |
| 4014 | 4008 | ||
| 4015 | inchannel = p->infd; | ||
| 4016 | |||
| 4017 | /* Beware SIGCHLD hereabouts. */ | 4009 | /* Beware SIGCHLD hereabouts. */ |
| 4018 | if (inchannel >= 0) | ||
| 4019 | flush_pending_output (inchannel); | ||
| 4020 | 4010 | ||
| 4021 | for (i = 0; i < PROCESS_OPEN_FDS; i++) | 4011 | for (i = 0; i < PROCESS_OPEN_FDS; i++) |
| 4022 | close_process_fd (&p->open_fd[i]); | 4012 | close_process_fd (&p->open_fd[i]); |
| 4023 | 4013 | ||
| 4014 | inchannel = p->infd; | ||
| 4024 | if (inchannel >= 0) | 4015 | if (inchannel >= 0) |
| 4025 | { | 4016 | { |
| 4026 | p->infd = -1; | 4017 | p->infd = -1; |
| @@ -5928,10 +5919,9 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, | |||
| 5928 | return; | 5919 | return; |
| 5929 | } | 5920 | } |
| 5930 | 5921 | ||
| 5931 | switch (signo) | ||
| 5932 | { | ||
| 5933 | #ifdef SIGCONT | 5922 | #ifdef SIGCONT |
| 5934 | case SIGCONT: | 5923 | if (signo == SIGCONT) |
| 5924 | { | ||
| 5935 | p->raw_status_new = 0; | 5925 | p->raw_status_new = 0; |
| 5936 | pset_status (p, Qrun); | 5926 | pset_status (p, Qrun); |
| 5937 | p->tick = ++process_tick; | 5927 | p->tick = ++process_tick; |
| @@ -5940,14 +5930,8 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, | |||
| 5940 | status_notify (NULL); | 5930 | status_notify (NULL); |
| 5941 | redisplay_preserve_echo_area (13); | 5931 | redisplay_preserve_echo_area (13); |
| 5942 | } | 5932 | } |
| 5943 | break; | ||
| 5944 | #endif /* ! defined (SIGCONT) */ | ||
| 5945 | case SIGINT: | ||
| 5946 | case SIGQUIT: | ||
| 5947 | case SIGKILL: | ||
| 5948 | flush_pending_output (p->infd); | ||
| 5949 | break; | ||
| 5950 | } | 5933 | } |
| 5934 | #endif | ||
| 5951 | 5935 | ||
| 5952 | /* If we don't have process groups, send the signal to the immediate | 5936 | /* If we don't have process groups, send the signal to the immediate |
| 5953 | subprocess. That isn't really right, but it's better than any | 5937 | subprocess. That isn't really right, but it's better than any |