diff options
| author | Paul Eggert | 2012-10-12 17:52:01 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-10-12 17:52:01 -0700 |
| commit | d6453ce49724b0a3bd24922ff0ad02f391d6e517 (patch) | |
| tree | 655b2ca5f792dc2058ad731a4c1bb5af89163b28 /src/process.c | |
| parent | 06485aa8215af39f9f5f999933aa39d349a2bdf9 (diff) | |
| download | emacs-d6453ce49724b0a3bd24922ff0ad02f391d6e517.tar.gz emacs-d6453ce49724b0a3bd24922ff0ad02f391d6e517.zip | |
Fix some stat-related races.
* fileio.c (Fwrite_region): Avoid race condition if a file is
removed or renamed by some other process immediately after Emacs
writes it but before Emacs stats it. Do not assume that stat (or
fstat) succeeds.
* image.c (slurp_file): Resolve the file name with fopen + fstat
rather than stat + fopen.
(pbm_read_file) [0]: Remove unused code with stat race.
* process.c (allocate_pty) [HAVE_PTYS && !PTY_ITERATION && !PTY_OPEN]:
Remove ineffective code with stat race.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/src/process.c b/src/process.c index 2cbce9d28ea..d45a2c6e8e0 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -646,23 +646,6 @@ allocate_pty (void) | |||
| 646 | PTY_OPEN; | 646 | PTY_OPEN; |
| 647 | #else /* no PTY_OPEN */ | 647 | #else /* no PTY_OPEN */ |
| 648 | { | 648 | { |
| 649 | { /* Some systems name their pseudoterminals so that there are gaps in | ||
| 650 | the usual sequence - for example, on HP9000/S700 systems, there | ||
| 651 | are no pseudoterminals with names ending in 'f'. So we wait for | ||
| 652 | three failures in a row before deciding that we've reached the | ||
| 653 | end of the ptys. */ | ||
| 654 | int failed_count = 0; | ||
| 655 | struct stat stb; | ||
| 656 | |||
| 657 | if (stat (pty_name, &stb) < 0) | ||
| 658 | { | ||
| 659 | failed_count++; | ||
| 660 | if (failed_count >= 3) | ||
| 661 | return -1; | ||
| 662 | } | ||
| 663 | else | ||
| 664 | failed_count = 0; | ||
| 665 | } | ||
| 666 | # ifdef O_NONBLOCK | 649 | # ifdef O_NONBLOCK |
| 667 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); | 650 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); |
| 668 | # else | 651 | # else |