aboutsummaryrefslogtreecommitdiffstats
path: root/src/termcap.c
diff options
context:
space:
mode:
authorPaul Eggert2013-07-11 19:03:47 -0700
committerPaul Eggert2013-07-11 19:03:47 -0700
commitbacba3c26522ef297662bace31947d3e4f47c87a (patch)
tree7937ff9ad18bca16aff3ecf1f791632a8dec2ce3 /src/termcap.c
parent1048af7c8ff6e8a84f802fbe655b95c261a6afc0 (diff)
downloademacs-bacba3c26522ef297662bace31947d3e4f47c87a.tar.gz
emacs-bacba3c26522ef297662bace31947d3e4f47c87a.zip
Fix races with threads and file descriptors.
* configure.ac (PTY_TTY_NAME_SPRINTF): Use emacs_close, not close. * src/callproc.c (Fcall_process_region): * src/dired.c (open_directory): * src/emacs.c (main, Fdaemon_initialized): * src/image.c (x_find_image_file): * src/inotify.c (Finotify_rm_watch): * src/lread.c (Flocate_file_internal): * src/process.c (Fnetwork_interface_list, Fnetwork_interface_info): * src/term.c (term_mouse_moveto, init_tty): * src/termcap.c (tgetent): * src/unexaix.c, src/unexcoff.c (report_error, report_error_1, adjust_lnnoptrs) * src/unexaix.c, src/unexcoff.c, src/unexcw.c, src/unexelf.c (unexec): * src/unexhp9k800.c, src/unexmacosx.c (unexec): * src/callproc.c (Fcall_process_region): Use emacs_close, not close. * src/sysdep.c (POSIX_CLOSE_RESTART, posix_close) [!POSIX_CLOSE_RESTART]: New macro and function, which emulates the POSIX_CLOSE_RESTART macro and posix_close function on current platforms (which all lack them). (emacs_close): Use it. This should fix the races on GNU/Linux and on AIX and on future platforms that support POSIX_CLOSE_RESTART, and it should avoid closing random victim file descriptors on other platforms.
Diffstat (limited to 'src/termcap.c')
-rw-r--r--src/termcap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/termcap.c b/src/termcap.c
index 5f731077463..be05828eea6 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -455,7 +455,7 @@ tgetent (char *bp, const char *name)
455 /* Scan the file, reading it via buf, till find start of main entry. */ 455 /* Scan the file, reading it via buf, till find start of main entry. */
456 if (scan_file (term, fd, &buf) == 0) 456 if (scan_file (term, fd, &buf) == 0)
457 { 457 {
458 close (fd); 458 emacs_close (fd);
459 xfree (buf.beg); 459 xfree (buf.beg);
460 if (malloc_size) 460 if (malloc_size)
461 xfree (bp); 461 xfree (bp);
@@ -493,7 +493,7 @@ tgetent (char *bp, const char *name)
493 term = tgetst1 (tc_search_point, (char **) 0); 493 term = tgetst1 (tc_search_point, (char **) 0);
494 } 494 }
495 495
496 close (fd); 496 emacs_close (fd);
497 xfree (buf.beg); 497 xfree (buf.beg);
498 498
499 if (malloc_size) 499 if (malloc_size)