<br><br><div class="gmail_quote">On Tue, Jun 9, 2009 at 09:28, Michael McMahon <span dir="ltr"><<a href="mailto:Michael.McMahon@sun.com">Michael.McMahon@sun.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Martin Buchholz wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
In the old implementation, we used the strategy of<br>
fork+mutate environ+execvp<br>
and we got the traditional shell script semantics<br>
from our use of execvp.<br>
Since environ is now a global shared-with-parent variable,<br>
we can't mutate it any more, therefore can't use execvp,<br>
and must implement the missing execvpe ourselves.<br>
</blockquote></div></blockquote><div><br>One more note: we could try to have two implementations of<br>execvpe, one that mutated environ and one that didn't,<br>since each has its own advantages,<br>but I think that would be even harder to understand and maintain.<br>
<br>Hmmmmmmmmmmmmmmmmmm.............................<br>Looking at the code again, it seems like it would not be too much work.<br><br>Here's an untested example of how we could do both.<br><br>static void<br>execve_with_shell_fallback(const char *file,<br>
const char *argv[],<br> const char *const envp[])<br>{<br>#if USE_CLONE<br> execve(file, (char **) argv, (char **) envp);<br> if (errno == ENOEXEC)<br> execve_as_traditional_shell_script(file, argv, envp);<br>
#else<br> extern char **environ;<br> environ = (char **) envp;<br> execvp(file, (char **) argv);<br>#endif<br>}<br><br>What do you think?<br><br>Martin<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Now, strictly speaking, execvp's traditional shell script semantics<br>
is an unspecified implementation detail of execvp;<br>
on other Unix platforms we might not need this. We can leave this to, e.g. the BSD porters reading this,<br>
to add some #ifdefs.<br>
<br>
</blockquote></div>
Ok, got you.<div class="im"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
(It would also be good if you ran the updated tests on<br>
Solaris with the old implementation to confirm my understanding)<br>
</blockquote>
<br></div>
I'm just building it now, and will run the test then.<br>
<br>
Thanks,<br><font color="#888888">
Michael.<br>
</font></blockquote></div><br>