aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-02-02 16:58:13 +0000
committerChristopher Faylor <me@cgf.cx>2012-02-02 16:58:13 +0000
commitab1fb5350595bcc80073b8ff8140ad09f4c01597 (patch)
treee03f47b41ed5ab2d1bc1161d0a99301024f02fcb /winsup/cygwin/syscalls.cc
parentb2ec6677eda5e44ee3d34df14a60dbee28a0e406 (diff)
downloadnewlib-ab1fb5350595bcc80073b8ff8140ad09f4c01597.zip
newlib-ab1fb5350595bcc80073b8ff8140ad09f4c01597.tar.gz
newlib-ab1fb5350595bcc80073b8ff8140ad09f4c01597.tar.bz2
* syscalls.cc (close_all_files): Use cygheap_fdget to manipulate fhandler. Use
debug_only_printf.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 3ed0f4f..a14774e 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -90,23 +90,23 @@ close_all_files (bool norelease)
semaphore::terminate ();
- fhandler_base *fh;
HANDLE h = NULL;
for (int i = 0; i < (int) cygheap->fdtab.size; i++)
- if ((fh = cygheap->fdtab[i]) != NULL)
- {
-#ifdef DEBUGGING
- debug_printf ("closing fd %d", i);
-#endif
- if (i == 2)
- DuplicateHandle (GetCurrentProcess (), fh->get_output_handle (),
- GetCurrentProcess (), &h,
- 0, false, DUPLICATE_SAME_ACCESS);
- fh->close_with_arch ();
- if (!norelease)
- cygheap->fdtab.release (i);
- }
+ {
+ cygheap_fdget cfd (i);
+ if (cfd >= 0)
+ {
+ debug_only_printf ("closing fd %d", i);
+ if (i == 2)
+ DuplicateHandle (GetCurrentProcess (), cfd->get_output_handle (),
+ GetCurrentProcess (), &h,
+ 0, false, DUPLICATE_SAME_ACCESS);
+ cfd->close_with_arch ();
+ if (!norelease)
+ cfd.release ();
+ }
+ }
if (!have_execed && cygheap->ctty)
cygheap->close_ctty ();