From: Johannes Sixt <j6t@kdbg.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [Replacement PATCH 1/7] MinGW: truncate exit()'s argument to lowest 8 bits
Date: Sun, 5 Jul 2009 20:57:46 +0200 [thread overview]
Message-ID: <200907052057.46200.j6t@kdbg.org> (raw)
In-Reply-To: <b73cf4b4cd09f4225098e71182044f64e12380aa.1246734159.git.j6t@kdbg.org>
For some reason, MinGW's bash cannot reliably detect failure of the child
process if a negative value is passed to exit(). This fixes it by
truncating the exit code in all calls of exit().
This issue was worked around in run_builtin() of git.c (2488df84 builtin
run_command: do not exit with -1, 2007-11-15). This workaround is no longer
necessary and is reverted.
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
compat/mingw.h | 2 ++
git.c | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/compat/mingw.h b/compat/mingw.h
index 4f7ba4c..c1859c5 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -92,6 +92,8 @@ static inline int fcntl(int fd, int cmd, long arg)
errno = EINVAL;
return -1;
}
+/* bash cannot reliably detect negative return codes as failure */
+#define exit(code) exit((code) & 0xff)
/*
* simple adaptors
diff --git a/git.c b/git.c
index f4d53f4..65ed733 100644
--- a/git.c
+++ b/git.c
@@ -245,7 +245,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
status = p->fn(argc, argv, prefix);
if (status)
- return status & 0xff;
+ return status;
/* Somebody closed stdout? */
if (fstat(fileno(stdout), &st))
--
1.6.3.3.393.g6b649
prev parent reply other threads:[~2009-07-05 18:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-04 19:26 [PATCH 0/7] rework run_command error reporting Johannes Sixt
2009-07-04 19:26 ` [PATCH 1/7] Truncate result of run_command that is used in exit() to lowest 8 bits Johannes Sixt
2009-07-04 19:26 ` [PATCH 2/7] MinGW: simplify waitpid() emulation macros Johannes Sixt
2009-07-04 19:26 ` [PATCH 3/7] run_command: return exit code as positive value Johannes Sixt
2009-07-04 19:26 ` [PATCH 4/7] run_command: report system call errors instead of returning error codes Johannes Sixt
2009-07-04 19:26 ` [PATCH 5/7] run_command: encode deadly signal number in the return value Johannes Sixt
2009-07-04 19:26 ` [PATCH 6/7] run_command: report failure to execute the program, but optionally don't Johannes Sixt
2009-07-04 19:26 ` [PATCH/RFC 7/7] receive-pack: remove unnecessary run_status report Johannes Sixt
2009-07-05 19:01 ` [PATCH 4/7] run_command: report system call errors instead of returning error codes Johannes Sixt
2009-07-05 19:14 ` Junio C Hamano
2009-07-06 7:37 ` Johannes Sixt
2009-07-05 18:57 ` Johannes Sixt [this message]
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=200907052057.46200.j6t@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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;
as well as URLs for NNTP newsgroup(s).