-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fork improvements #2907
Fork improvements #2907
Conversation
@@ -3109,7 +3153,7 @@ UInt SyExecuteProcess ( | |||
func2 = &NullSignalHandler; | |||
|
|||
/* clone the process */ | |||
pid = vfork(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the use of vfork
here is/was meant as an optimization that preserves memory and is also easier to implement on, say, Windows, than full fork
. This PR silently changes it to fork
, a deoptimization. Do we really want that? Perhaps a SyVFork
is needed, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec for vfork
says the only functions you are allowed to call after a vfork
is _exit
or exec*
. We are calling chdir
, open
, fcntl
and SyBufFileno
(which is one of our functions, but I believe even that isn't acceptable). I can't find any spec that says that's acceptable, even on Linux. However, I shouldn't have bundled this into the same PR, as if we want to keep vfork a SyVfork would be easy to add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, cygwin's vfork just calls fork it turns out (from some mailing list reading), although I think linux vfork actually does "proper" vfork.
|
||
/* | ||
*F RegisterSyForkObserver( <func> ) | ||
** Register a function to be called before and after fork is called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, when adding documentation comments, I'd either make them match the existing ones, or radically different; but this is kind of a mishmash (only one space after **
, no empty line after the *F
line, no start line with /*****
.
If you don't mind, I can amend this PR accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to adjust it. I want to look at why hpc-gap is crashing (I suspect switching vfork for fork, which suprises me, as I expected that to make hpc-gap more stable, not less.
Oh, I also removed a use of |
I've realised, on further use, that this PR is actually not really want I wanted at the moment. I think I want to distinguish in the child between:
|
closing because this was a stupid idea. Sorry. |
This PR adds
SyFork
, a wrapper around for which allows functions to be called pre- and post- fork. Profiling then uses this to create a new profile output for each child, to avoid the profile output getting corrupted.If/when this is merged, I will force the IO package to use SyFork (when it is available), so forks which happen in IO can also be tracked.