Re: t5570-git-daemon fails with SIGPIPE on OSX
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Mar 3, 2019, 14:56 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1903031551540.45@tvgsbejvaqbjf.bet>
- In-Reply-To
- <xmqq8sxw69d5.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Sun, 3 Mar 2019, Junio C Hamano wrote:
Show 14 quoted lines
> Jeff King <peff@peff.net> writes: > > > But for git-fetch, our primary purpose is receiving data and writing it > > to disk. We should be checking all of our write()s already, and SIGPIPE > > is just confusing. > > Yup, sounds like a very sensible argument. > > > So I'd actually be fine with just declaring that certain commands (like > > fetch) just ignore SIGPIPE entirely. > > Me too (to me, "actually be fine with" would mean "that's a larger > hammer alternative, which is OK, while the base solution is fine, > too").
So do I understand that you'd like something like this?
-- snipsnap -- t a/git.c b/git.c index 2f604a41ea..c4122cc699 100644
--- a/git.c +++ b/git.c @@ -4,6 +4,7 @@ #include "help.h" #include "run-command.h" #include "alias.h" +#include "sigchain.h" #define RUN_SETUP (1<<0) #define RUN_SETUP_GENTLY (1<<1) @@ -16,6 +17,7 @@ #define SUPPORT_SUPER_PREFIX (1<<4) #define DELAY_PAGER_CONFIG (1<<5) #define NO_PARSEOPT (1<<6) /* parse-options is not used */ +#define IGNORE_SIGPIPE (1<<7) struct cmd_struct { const char *cmd; @@ -388,6 +390,8 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) prefix = NULL; help = argc == 2 && !strcmp(argv[1], "-h"); if (!help) { + if (p->option & IGNORE_SIGPIPE) + sigchain_push(SIGPIPE, SIG_IGN); if (p->option & RUN_SETUP) prefix = setup_git_directory(); else if (p->option & RUN_SETUP_GENTLY) { @@ -477,7 +481,7 @@ static struct cmd_struct commands[] = { { "diff-tree", cmd_diff_tree, RUN_SETUP | NO_PARSEOPT }, { "difftool", cmd_difftool, RUN_SETUP | NEED_WORK_TREE }, { "fast-export", cmd_fast_export, RUN_SETUP }, - { "fetch", cmd_fetch, RUN_SETUP }, + { "fetch", cmd_fetch, RUN_SETUP | IGNORE_SIGPIPE }, { "fetch-pack", cmd_fetch_pack, RUN_SETUP | NO_PARSEOPT }, { "fmt-merge-msg", cmd_fmt_merge_msg, RUN_SETUP }, { "for-each-ref", cmd_for_each_ref, RUN_SETUP },