<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 12, 2016 at 5:49 PM, Rob Landley <span dir="ltr"><<a href="mailto:rob@landley.net" target="_blank">rob@landley.net</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">So... no? I think? Is there a way _I_ can tag this? (I can't do my own<br>
vfork prototype because I can't #undef the one I get out of unistd.h and<br>
that's a fairly generic header. It's sad I can't redo function<br>
prototypes after the fact, but the language never gave me a way to.<br>
Maybe I could do a gratuitous wrapper around it?)<br></blockquote><div><br></div><div>gcc seems to do the equivalent automatically for any function named "vfork": <a href="https://github.com/gcc-mirror/gcc/blob/e11be3ea01eaf8acd8cd86d3f9c427621b64e6b4/gcc/calls.c#L533">https://github.com/gcc-mirror/gcc/blob/e11be3ea01eaf8acd8cd86d3f9c427621b64e6b4/gcc/calls.c#L533</a></div><div><br></div><div>On Thu, Oct 13, 2016 at 1:03 AM, Rob Landley <span dir="ltr"><<a href="mailto:rob@landley.net" target="_blank">rob@landley.net</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">If I have to gratuitously call setjmp() and ignore its return value<br>right before calling vfork() to beat reliable behavior out of gcc, I can<br>do that. I can also use global variables instead of local variables, or<br>make a structure of local variables so gcc can't gratuitously reorganize<br>them and trim the stack, or have my one allowed <strike>phone</strike><br>function call be to a function I define that contains "everything the<br>child does" to preserve the stack context.<br><br>Personally, I'd rather the compiler didn't fight me when I'm trying to<br>do something obvious, but I have LOTS of ways to fight back. :)</blockquote><div> </div></div><div>It doesn't seem like gcc differentiates between vfork, setjmp, etc. so it's presumably providing some behavior that satisfies the constraints of all of them (or there's a bug). The specification for longjmp says that only non-volatile local variables that get modified have unspecified values, so you could maybe try sprinkling volatile on things to see if it makes your problem go away?</div></div></div></div>