diff options
author | Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com> | 2016-12-07 11:58:28 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2019-02-07 15:58:02 +0100 |
commit | ece7282f329fd3616a9a1089aa0f0c26a5c01cc1 (patch) | |
tree | a40d53da4980658c85e293d02730b8b15d9c0c9b /winsup/cygwin/dcrt0.cc | |
parent | 8ddb1f60c8bd5a1e6c64b2e713480bc7bc386328 (diff) | |
download | newlib-ece7282f329fd3616a9a1089aa0f0c26a5c01cc1.zip newlib-ece7282f329fd3616a9a1089aa0f0c26a5c01cc1.tar.gz newlib-ece7282f329fd3616a9a1089aa0f0c26a5c01cc1.tar.bz2 |
forkables: On fork failure, retry with hardlinks.
To support in-cygwin package managers, the fork() implementation must
not rely on .exe and .dll files to stay in their original location, as
the package manager's job is to replace these files. Instead, when the
first fork try fails, and we have NTFS, we use hardlinks to the original
binaries in /var/run/cygfork/ to create the child process during the
second fork try, along the main.exe.local file to enable the "DotLocal
Dll Redirection" feature for the dlls.
The (probably few) users that need an update-safe fork manually have to
create the /var/run/cygfork/ directory for now, using:
mkdir --mode=a=rwxt /var/run/cygfork
* child_info.h: Bump CURR_CHILD_INFO_MAGIC.
(enum child_status): Add _CI_SILENTFAIL flag.
(struct child_info): Add silentfail setter and getter.
* winsup.h (child_copy): Add bool silentfail parameter.
* cygheap.cc: Pass silentfail parameter to child_copy.
* dcrt0.cc: Ditto.
* dll_init.h (struct dll): Define public inline method forkedntname.
(struct dll_list): Declare private method find_by_forkedntname.
* dll_init.cc (struct dll_list): Implement find_by_forkedntname.
(dll_list::alloc): Use find_by_forkedntname when in load after fork.
(dll_list::load_after_fork_impl): Load dlls using dll::forkedntname.
* fork.cc (frok::parent): Set silentfail child info flag. Pass
silentfail parameter to child_copy. Use forkedntname of
dlls.main_executable.
(fork): When first dofork run failed and did not use forkables,
run dofork again with_forkables set to true.
(child_copy): Use debug_printf if silentfail is true,
system_printf otherwise.
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 5cdf01c..78506d4 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -601,7 +601,7 @@ child_info_fork::handle_fork () myself->uid = cygheap->user.real_uid; myself->gid = cygheap->user.real_gid; - child_copy (parent, false, + child_copy (parent, false, silentfail (), "dll data", dll_data_start, dll_data_end, "dll bss", dll_bss_start, dll_bss_end, "user heap", cygheap->user_heap.base, cygheap->user_heap.ptr, @@ -625,7 +625,7 @@ child_info_fork::handle_fork () /* step 2 now that the dll has its heap filled in, we can fill in the user's data and bss since user_data is now filled out. */ - child_copy (parent, false, + child_copy (parent, false, silentfail (), "data", user_data->data_start, user_data->data_end, "bss", user_data->bss_start, user_data->bss_end, NULL); |