From: Linus Torvalds <torvalds@linux-foundation.org>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>,
Steffen Prohaska <prohaska@zib.de>,
Johannes Sixt <johannes.sixt@telecom.at>,
msysGit <msysgit@googlegroups.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Should we discuss Windows-related changes on git@vger.kernel.org?
Date: Fri, 11 Jul 2008 18:07:34 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.1.10.0807111750200.2875@woody.linux-foundation.org> (raw)
In-Reply-To: <alpine.LFD.1.10.0807111653500.2875@woody.linux-foundation.org>
On Fri, 11 Jul 2008, Linus Torvalds wrote:
>
> If it's something that should be merged, and if it concerns code that I'm
> interested in, I want to know about it. It's that simple.
Btw, an example of where I think we need to look at both windows and unix
behavior and not try to make them two different camps is in that
"start_command()" thing.
It was changed to have a totally separate __MINGW32__ part, but the thing
is, the unix side could really be improved - and actually made more like
the MINGW32 code at the same time!
For example, on many systems it is rather noticeably faster to use
"vfork+execve" than it is to do "fork+execve", because you avoid a whole
"duplicate and tear down page tables" sequence. So the UNIX code would
actually be better off using "vfork()" instead of "fork()" there.
But it can't right now - because if "cmd->env" changes the environment, it
would change it both in the caller and in the result.
It turns out that Windows has the exact same issue (because it uses a
spawn thing), and already does a "copy_env() + change-in-copy + free"
model for that reason.
If that was shared, the UNIX side could just use vfork, I believe. In
fact, the following trivial - but horribly ugly - patch passes all the
tests, by doing the vfork() in all cases except when the environment
changes. But I don't know what coverage that has, though (maybe env is
effectively always set?).
And I suspect there are other cases where we'd actually be better off
trying to share things than having all the differences hidden away in
compat layers.
Linus
---
builtin-grep.c | 2 +-
run-command.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin-grep.c b/builtin-grep.c
index ef29910..5d3053a 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -168,7 +168,7 @@ static int exec_grep(int argc, const char **argv)
int status;
argv[argc] = NULL;
- pid = fork();
+ pid = vfork();
if (pid < 0)
return pid;
if (!pid) {
diff --git a/run-command.c b/run-command.c
index 6e29fdf..200ba7b 100644
--- a/run-command.c
+++ b/run-command.c
@@ -68,7 +68,7 @@ int start_command(struct child_process *cmd)
trace_argv_printf(cmd->argv, "trace: run_command:");
#ifndef __MINGW32__
- cmd->pid = fork();
+ cmd->pid = cmd->env ? fork() : vfork();
if (!cmd->pid) {
if (cmd->no_stdin)
dup_devnull(0);
next prev parent reply other threads:[~2008-07-12 1:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-11 8:07 Should we discuss Windows-related changes on git@vger.kernel.org? Steffen Prohaska
2008-07-11 11:56 ` Johannes Schindelin
2008-07-11 15:51 ` Steffen Prohaska
2008-07-11 15:57 ` Johannes Schindelin
2008-07-11 16:24 ` Steffen Prohaska
2008-07-11 18:36 ` Johannes Schindelin
2008-07-11 19:04 ` Linus Torvalds
2008-07-11 19:40 ` Johannes Schindelin
2008-07-11 21:10 ` Steffen Prohaska
2008-07-11 21:38 ` Johannes Schindelin
2008-07-11 23:06 ` Junio C Hamano
2008-07-11 23:37 ` Johannes Schindelin
2008-07-12 8:07 ` Steffen Prohaska
2008-07-11 22:14 ` Junio C Hamano
2008-07-11 23:35 ` Johannes Schindelin
2008-07-11 23:40 ` Linus Torvalds
2008-07-11 23:47 ` Johannes Schindelin
2008-07-11 23:58 ` Linus Torvalds
2008-07-12 0:06 ` Johannes Schindelin
2008-07-12 1:07 ` Linus Torvalds [this message]
2008-07-12 7:38 ` Steffen Prohaska
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.1.10.0807111750200.2875@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.sixt@telecom.at \
--cc=msysgit@googlegroups.com \
--cc=prohaska@zib.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox