diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/process.c b/src/process.c index 17fe708a954..b4f979fd484 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -658,22 +658,24 @@ allocate_pty (char pty_name[PTY_NAME_SIZE]) | |||
| 658 | 658 | ||
| 659 | if (fd >= 0) | 659 | if (fd >= 0) |
| 660 | { | 660 | { |
| 661 | #ifdef PTY_OPEN | 661 | #ifdef PTY_TTY_NAME_SPRINTF |
| 662 | PTY_TTY_NAME_SPRINTF | ||
| 663 | #else | ||
| 664 | sprintf (pty_name, "/dev/tty%c%x", c, i); | ||
| 665 | #endif /* no PTY_TTY_NAME_SPRINTF */ | ||
| 666 | |||
| 662 | /* Set FD's close-on-exec flag. This is needed even if | 667 | /* Set FD's close-on-exec flag. This is needed even if |
| 663 | PT_OPEN calls posix_openpt with O_CLOEXEC, since POSIX | 668 | PT_OPEN calls posix_openpt with O_CLOEXEC, since POSIX |
| 664 | doesn't require support for that combination. | 669 | doesn't require support for that combination. |
| 670 | Do this after PTY_TTY_NAME_SPRINTF, which on some platforms | ||
| 671 | doesn't work if the close-on-exec flag is set (Bug#20555). | ||
| 665 | Multithreaded platforms where posix_openpt ignores | 672 | Multithreaded platforms where posix_openpt ignores |
| 666 | O_CLOEXEC (or where PTY_OPEN doesn't call posix_openpt) | 673 | O_CLOEXEC (or where PTY_OPEN doesn't call posix_openpt) |
| 667 | have a race condition between the PTY_OPEN and here. */ | 674 | have a race condition between the PTY_OPEN and here. */ |
| 668 | fcntl (fd, F_SETFD, FD_CLOEXEC); | 675 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
| 669 | #endif | 676 | |
| 670 | /* Check to make certain that both sides are available | 677 | /* Check to make certain that both sides are available. |
| 671 | this avoids a nasty yet stupid bug in rlogins. */ | 678 | This avoids a nasty yet stupid bug in rlogins. */ |
| 672 | #ifdef PTY_TTY_NAME_SPRINTF | ||
| 673 | PTY_TTY_NAME_SPRINTF | ||
| 674 | #else | ||
| 675 | sprintf (pty_name, "/dev/tty%c%x", c, i); | ||
| 676 | #endif /* no PTY_TTY_NAME_SPRINTF */ | ||
| 677 | if (faccessat (AT_FDCWD, pty_name, R_OK | W_OK, AT_EACCESS) != 0) | 679 | if (faccessat (AT_FDCWD, pty_name, R_OK | W_OK, AT_EACCESS) != 0) |
| 678 | { | 680 | { |
| 679 | emacs_close (fd); | 681 | emacs_close (fd); |