diff options
| author | Paul Eggert | 2013-08-20 22:39:51 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-08-20 22:39:51 -0700 |
| commit | 0d7c1e66ffad14f76fbd226d50113a61c738806c (patch) | |
| tree | d88329f436b0cc3069c1dc118795efa2dd2f0e64 /src/process.c | |
| parent | 6e50e9836a5e539cf2286fff44e9966e074f9c7b (diff) | |
| download | emacs-0d7c1e66ffad14f76fbd226d50113a61c738806c.tar.gz emacs-0d7c1e66ffad14f76fbd226d50113a61c738806c.zip | |
* process.c (allocate_pty) [PTY_OPEN]: Set fd's FD_CLOEXEC flag.
We can't portably rely on PTY_OPEN doing that, even if
it calls posix_openpt with O_CLOEXEC.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/process.c b/src/process.c index c4dd87a6b48..349ec26534b 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -687,6 +687,15 @@ allocate_pty (char pty_name[PTY_NAME_SIZE]) | |||
| 687 | 687 | ||
| 688 | if (fd >= 0) | 688 | if (fd >= 0) |
| 689 | { | 689 | { |
| 690 | #ifdef PTY_OPEN | ||
| 691 | /* Set FD's close-on-exec flag. This is needed even if | ||
| 692 | PT_OPEN calls posix_openpt with O_CLOEXEC, since POSIX | ||
| 693 | doesn't require support for that combination. | ||
| 694 | Multithreaded platforms where posix_openpt ignores | ||
| 695 | O_CLOEXEC (or where PTY_OPEN doesn't call posix_openpt) | ||
| 696 | have a race condition between the PTY_OPEN and here. */ | ||
| 697 | fcntl (fd, F_SETFD, FD_CLOEXEC); | ||
| 698 | #endif | ||
| 690 | /* check to make certain that both sides are available | 699 | /* check to make certain that both sides are available |
| 691 | this avoids a nasty yet stupid bug in rlogins */ | 700 | this avoids a nasty yet stupid bug in rlogins */ |
| 692 | #ifdef PTY_TTY_NAME_SPRINTF | 701 | #ifdef PTY_TTY_NAME_SPRINTF |