aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-10-17 17:45:09 +0000
committerChristopher Faylor <me@cgf.cx>2002-10-17 17:45:09 +0000
commitfef1edbc9a4ca63fdb801f78086d442bce1da40f (patch)
treed05317f5b2ba6fe622957cad2bc93157393dbdd9 /winsup/cygwin
parente9350b6575f296f1e46a867480112300498b467b (diff)
downloadnewlib-fef1edbc9a4ca63fdb801f78086d442bce1da40f.zip
newlib-fef1edbc9a4ca63fdb801f78086d442bce1da40f.tar.gz
newlib-fef1edbc9a4ca63fdb801f78086d442bce1da40f.tar.bz2
* dtable.cc (dtable::set_file_pointers_for_exec): New function.
* dtable.h (dtable::set_file_pointers_for_exec): Declare new function. * spawn.cc (spawn_guts): Call dtable::set_file_pointers_for_exec to set pointers to EOF when execing non-cygwin applications.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/dtable.cc11
-rw-r--r--winsup/cygwin/dtable.h1
-rw-r--r--winsup/cygwin/spawn.cc1
4 files changed, 20 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 4c170f2..f51f0a4 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2002-10-17 Christopher Faylor <cgf@redhat.com>
+
+ * dtable.cc (dtable::set_file_pointers_for_exec): New function.
+ * dtable.h (dtable::set_file_pointers_for_exec): Declare new function.
+ * spawn.cc (spawn_guts): Call dtable::set_file_pointers_for_exec to set
+ pointers to EOF when execing non-cygwin applications.
+
2002-10-17 Robert Collins <rbtcollins@hotmail.com>
* thread.h (pthread_mutex::isGoodInitializerOrBadObject): Declare.
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 6b5ee88..7bbfbbf 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -575,6 +575,17 @@ dtable::fixup_before_exec (DWORD target_proc_id)
}
void
+dtable::set_file_pointers_for_exec ()
+{
+ SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "set_file_pointers_for_exec");
+ fhandler_base *fh;
+ for (size_t i = 0; i < size; i++)
+ if ((fh = fds[i]) != NULL && fh->get_flags () & O_APPEND)
+ SetFilePointer (fh->get_handle (), 0, 0, FILE_END);
+ ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_exec");
+}
+
+void
dtable::fixup_after_exec (HANDLE parent)
{
first_fd_for_open = 0;
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index c481810..0223af7 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -78,6 +78,7 @@ public:
operator fhandler_base **() {return fds;}
void stdio_init ();
void get_debugger_info ();
+ void set_file_pointers_for_exec ();
};
void dtable_init (void);
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 6bc76fb..9c055c8 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -621,6 +621,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
cygbench ("spawn-guts");
+ cygheap->fdtab.set_file_pointers_for_exec ();
if (!cygheap->user.issetuid ())
{
PSECURITY_ATTRIBUTES sec_attribs = sec_user_nih (sa_buf);