Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-03-11 20:57:22 +0300
committerCorinna Vinschen <corinna@vinschen.de>2002-03-11 20:57:22 +0300
commit713fb38b7c3f6bcf1d0c1bd845d2264b19a82439 (patch)
treea4c124b8d85c113c94113fc2cdb6fb52b89580ff /winsup
parenteabb48d53d6bfa3f8dd3564a6b789b6d37c94b65 (diff)
* fork.cc (fork_child): Call fixup_mmaps_after_fork() before
closing parent process handle. Call fixup_mmaps_after_fork() with parent process handle as parameter. * mmap.cc (mmap_record::access): New method. (fixup_mmaps_after_fork): Take process handle as parameter. In case of FILE_MAP_COPY access, copy valid memory regions to child. * pinfo.h (fixup_mmaps_after_fork): Change prototype accordingly.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog10
-rw-r--r--winsup/cygwin/fork.cc6
-rw-r--r--winsup/cygwin/mmap.cc26
-rw-r--r--winsup/cygwin/pinfo.h2
4 files changed, 39 insertions, 5 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 3029b839e..fa15f2ce1 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,13 @@
+2002-03-11 Corinna Vinschen <corina@vinschen.de>
+
+ * fork.cc (fork_child): Call fixup_mmaps_after_fork() before
+ closing parent process handle. Call fixup_mmaps_after_fork()
+ with parent process handle as parameter.
+ * mmap.cc (mmap_record::access): New method.
+ (fixup_mmaps_after_fork): Take process handle as parameter.
+ In case of FILE_MAP_COPY access, copy valid memory regions to child.
+ * pinfo.h (fixup_mmaps_after_fork): Change prototype accordingly.
+
2002-03-07 Corinna Vinschen <corina@vinschen.de>
* autoload.cc (NetGetDCName): Add symbol.
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index f7133df6b..03d17ee65 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -296,13 +296,13 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
sync_with_parent ("loaded dlls", TRUE);
}
+ if (fixup_mmaps_after_fork (hParent))
+ api_fatal ("recreate_mmaps_after_fork_failed");
+
ForceCloseHandle (hParent);
(void) ForceCloseHandle (child_proc_info->subproc_ready);
(void) ForceCloseHandle (child_proc_info->forker_finished);
- if (fixup_mmaps_after_fork ())
- api_fatal ("recreate_mmaps_after_fork_failed");
-
if (fixup_shms_after_fork ())
api_fatal ("recreate_shm areas after fork failed");
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 57bd82795..dae80e4d6 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -98,6 +98,7 @@ class mmap_record
__off64_t map_map (__off64_t off, DWORD len);
BOOL unmap_map (caddr_t addr, DWORD len);
void fixup_map (void);
+ int access (char *address);
fhandler_base *alloc_fh ();
void free_fh (fhandler_base *fh);
@@ -219,6 +220,15 @@ mmap_record::fixup_map ()
&old_prot);
}
+int
+mmap_record::access (char *address)
+{
+ if (address < base_address_ || address >= base_address_ + size_to_map_)
+ return 0;
+ DWORD off = (address - base_address_) / getpagesize ();
+ return MAP_ISSET (off);
+}
+
static fhandler_disk_file fh_paging_file;
fhandler_base *
@@ -887,7 +897,7 @@ mprotect (caddr_t addr, size_t len, int prot)
*/
int __stdcall
-fixup_mmaps_after_fork ()
+fixup_mmaps_after_fork (HANDLE parent)
{
debug_printf ("recreate_mmaps_after_fork, mmapped_areas %p", mmapped_areas);
@@ -925,6 +935,20 @@ fixup_mmaps_after_fork ()
rec->get_address ());
return -1;
}
+ if (rec->get_access () == FILE_MAP_COPY)
+ {
+ for (char *address = rec->get_address ();
+ address < rec->get_address () + rec->get_size ();
+ address += getpagesize ())
+ if (rec->access (address)
+ && !ReadProcessMemory (parent, address, address,
+ getpagesize (), NULL))
+ {
+ system_printf ("ReadProcessMemory failed for MAP_PRIVATE address %p, %E",
+ rec->get_address ());
+ return -1;
+ }
+ }
rec->fixup_map ();
}
}
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 1bc2f7919..dc16966b9 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -200,7 +200,7 @@ extern void __stdcall pinfo_fixup_after_fork ();
extern HANDLE hexec_proc;
/* For mmaps across fork(). */
-int __stdcall fixup_mmaps_after_fork ();
+int __stdcall fixup_mmaps_after_fork (HANDLE parent);
/* for shm areas across fork (). */
int __stdcall fixup_shms_after_fork ();