|
From: Jeremy F. <je...@go...> - 2003-12-18 07:23:17
|
CVS commit by fitzhardinge:
Fix a bug in the last VG_(max_fd) change; VG_(safe_fd) doesn't work before
VG_(max_fd) has been set up.
M +6 -6 vg_main.c 1.132
M +2 -0 vg_mylibc.c 1.62
--- valgrind/coregrind/vg_main.c #1.131:1.132
@@ -155,5 +155,5 @@ Int VG_(main_pgrp);
/* Maximum allowed application-visible file descriptor */
-Int VG_(max_fd);
+Int VG_(max_fd) = -1;
/* Words. */
@@ -1404,9 +1404,4 @@ void VG_(main) ( const KickstartParams *
vg_assert(VG_(clstk_end) == VG_(client_end));
- if (kp->vgexecfd != -1)
- VG_(vgexecfd) = VG_(safe_fd)(kp->vgexecfd);
- if (kp->clexecfd != -1)
- VG_(clexecfd) = VG_(safe_fd)(kp->clexecfd);
-
if (0) {
if (VG_(have_ssestate))
@@ -1438,4 +1433,9 @@ void VG_(main) ( const KickstartParams *
VG_(setrlimit)(VKI_RLIMIT_NOFILE, &rl);
+ if (kp->vgexecfd != -1)
+ VG_(vgexecfd) = VG_(safe_fd)(kp->vgexecfd);
+ if (kp->clexecfd != -1)
+ VG_(clexecfd) = VG_(safe_fd)(kp->clexecfd);
+
/* Read /proc/self/maps into a buffer. Must be before:
- SK_(pre_clo_init)(): so that if it calls VG_(malloc)(), any mmap'd
--- valgrind/coregrind/vg_mylibc.c #1.61:1.62
@@ -1204,4 +1204,6 @@ Int VG_(safe_fd)(Int oldfd)
Int newfd;
+ vg_assert(VG_(max_fd) != -1);
+
newfd = VG_(fcntl)(oldfd, VKI_F_DUPFD, VG_(max_fd)+1);
if (newfd != -1)
|