From: Johannes Sixt <J.Sixt@eudaptics.com>
To: git@vger.kernel.org
Subject: Re: [PATCH] Add git-bundle: move objects and references by archive
Date: Thu, 22 Feb 2007 10:31:11 +0100 [thread overview]
Message-ID: <45DD62DF.9324130F@eudaptics.com> (raw)
In-Reply-To: Pine.LNX.4.63.0702220157130.22628@wbgn013.biozentrum.uni-wuerzburg.de
Johannes Schindelin wrote:
> +/* if in && *in >= 0, take that as input file descriptor instead */
> +static int fork_with_pipe(const char **argv, int *in, int *out)
> +{
> + int needs_in, needs_out;
> + int fdin[2], fdout[2], pid;
> +
> + needs_in = in && *in < 0;
> + if (needs_in) {
> + if (pipe(fdin) < 0)
> + return error("could not setup pipe");
> + *in = fdin[1];
> + }
> +
> + needs_out = out && *out < 0;
> + if (needs_out) {
> + if (pipe(fdout) < 0)
> + return error("could not setup pipe");
> + *out = fdout[0];
> + }
> +
> + if ((pid = fork()) < 0) {
> + if (needs_in) {
> + close(fdin[0]);
> + close(fdin[1]);
> + }
> + if (needs_out) {
> + close(fdout[0]);
> + close(fdout[1]);
> + }
> + return error("could not fork");
> + }
> + if (!pid) {
> + if (needs_in) {
> + dup2(fdin[0], 0);
> + close(fdin[0]);
> + close(fdin[1]);
> + } else if (in)
> + dup2(*in, 0);
> + if (needs_out) {
> + dup2(fdout[1], 1);
> + close(fdout[0]);
> + close(fdout[1]);
> + } else if (out)
> + dup2(*out, 1);
> + exit(execv_git_cmd(argv));
> + }
> + if (needs_in)
> + close(fdin[0]);
> + if (needs_out)
> + close(fdout[1]);
> + return pid;
> +}
This function looks very similar to spawnvppe, which I use in the MinGW
port for a number of fork/exec pairs. Do you see a chance to make this
into a helper that can be used in more places (so that it reduces the
differences to the MinGW code)?
> + in = out = -1;
> + pid = fork_with_pipe(argv, &in, &out);
> + if (pid < 0)
> + return error("Could not fork rev-list");
> + if (!fork()) {
> + for (i = 0; i < p->nr; i++) {
> + write(in, sha1_to_hex(p->list[i].sha1), 40);
> + write(in, "\n", 1);
> + }
> + close(in);
> + exit(0);
> + }
> + close(in);
Oops, fork error check missing?
-- Hannes
next prev parent reply other threads:[~2007-02-22 9:37 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.63.0702220157130.22628@wbgn013.biozentrum.uni-wuerz burg.de>
2007-02-22 0:59 ` [PATCH] Add git-bundle: move objects and references by archive Johannes Schindelin
2007-02-22 3:28 ` Nicolas Pitre
2007-02-22 15:55 ` Johannes Schindelin
2007-02-22 16:14 ` Simon 'corecode' Schubert
2007-02-22 16:28 ` Nicolas Pitre
2007-02-22 16:37 ` Johannes Schindelin
2007-02-22 16:46 ` Simon 'corecode' Schubert
2007-02-22 17:09 ` Johannes Schindelin
2007-02-22 16:24 ` Nicolas Pitre
2007-02-22 17:12 ` Johannes Schindelin
2007-02-22 17:21 ` Nicolas Pitre
2007-02-22 6:56 ` Junio C Hamano
2007-02-22 7:08 ` Junio C Hamano
2007-02-22 16:20 ` Johannes Schindelin
2007-02-22 19:10 ` Junio C Hamano
2007-02-22 19:16 ` Johannes Schindelin
2007-02-22 20:05 ` Junio C Hamano
2007-02-22 20:25 ` Johannes Schindelin
2007-02-22 16:17 ` Johannes Schindelin
2007-02-23 2:32 ` Mark Levedahl
2007-02-23 4:39 ` Junio C Hamano
2007-02-22 9:31 ` Johannes Sixt [this message]
2007-02-22 18:14 ` [PATCH] git-bundle: assorted fixes Johannes Schindelin
2007-02-23 1:36 ` Mark Levedahl
2007-02-23 1:56 ` Johannes Schindelin
2007-02-23 2:12 ` Mark Levedahl
2007-02-23 2:17 ` Johannes Schindelin
2007-02-23 3:37 ` Mark Levedahl
2007-02-18 22:47 [PATCH] Add git-bundle: move objects and references by archive Mark Levedahl
2007-02-19 1:07 ` Johannes Schindelin
2007-02-19 1:50 ` Junio C Hamano
2007-02-19 2:02 ` Johannes Schindelin
2007-02-19 7:56 ` Shawn O. Pearce
2007-02-19 13:29 ` Mark Levedahl
2007-02-19 15:03 ` Johannes Schindelin
2007-02-19 1:49 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2007-02-17 18:41 [PATCH] Add git-unbundle - unpack objects and references for disconnected transfer Junio C Hamano
2007-02-18 17:27 ` [PATCH] Add git-bundle: move objects and references by archive Mark Levedahl
2007-02-18 22:47 ` Mark Levedahl
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=45DD62DF.9324130F@eudaptics.com \
--to=j.sixt@eudaptics.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.