git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/7] Truncate result of run_command that is used in exit() to lowest 8 bits

From
Johannes Sixt <j6t@kdbg.org>
Date
Jul 4, 2009, 19:26 UTC
Message-ID
<b73cf4b4cd09f4225098e71182044f64e12380aa.1246734159.git.j6t@kdbg.org>
In-Reply-To
<cover.1246734159.git.j6t@kdbg.org>

On Windows, negative return values are not detected reliably by the parent process as failure. This fixes it.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 bisect.c      |    4 ++--
 builtin-add.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/bisect.c b/bisect.c
index 52220df..b395c47 100644
--- a/bisect.c
+++ b/bisect.c
@@ -760,7 +760,7 @@ static int bisect_checkout(char *bisect_rev_hex)
 	argv_checkout[2] = bisect_rev_hex;
 	res = run_command_v_opt(argv_checkout, RUN_GIT_CMD);
 	if (res)
-		exit(res);
+		exit(res & 0xff);
 
 	argv_show_branch[1] = bisect_rev_hex;
 	return run_command_v_opt(argv_show_branch, RUN_GIT_CMD);
@@ -850,7 +850,7 @@ static void check_merge_bases(void)
 			handle_skipped_merge_base(mb);
 		} else {
 			printf("Bisecting: a merge base must be tested\n");
-			exit(bisect_checkout(sha1_to_hex(mb)));
+			exit(bisect_checkout(sha1_to_hex(mb)) & 0xff);
 		}
 	}
 
diff --git a/builtin-add.c b/builtin-add.c
index 4e44148..d83e67e 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -305,7 +305,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	if (patch_interactive)
 		add_interactive = 1;
 	if (add_interactive)
-		exit(interactive_add(argc - 1, argv + 1, prefix));
+		exit(interactive_add(argc - 1, argv + 1, prefix) & 0xff);
 
 	if (edit_interactive)
 		return(edit_patch(argc, argv, prefix));
-- 
1.6.3.17.g1665f
Previous: Johannes SixtNext: Johannes Sixt
Message 2 of 12 in “rework run_command error reporting”
  1. 0/7 rework run_command error reportingJohannes Sixt, Jul 4, 2009
  2. 1/7 Truncate result of run_command that is used in exit() to lowest 8 bitsJohannes Sixt, Jul 4, 2009
  3. 2/7 MinGW: simplify waitpid() emulation macrosJohannes Sixt, Jul 4, 2009
  4. 3/7 run_command: return exit code as positive valueJohannes Sixt, Jul 4, 2009
  5. 4/7 run_command: report system call errors instead of returning error codesJohannes Sixt, Jul 4, 2009
  6. 5/7 run_command: encode deadly signal number in the return valueJohannes Sixt, Jul 4, 2009
  7. 6/7 run_command: report failure to execute the program, but optionally don'tJohannes Sixt, Jul 4, 2009
  8. 7/7 receive-pack: remove unnecessary run_status reportJohannes Sixt, Jul 4, 2009
  9. Johannes SixtJul 5, 2009
  10. Junio C HamanoJul 5, 2009
  11. Johannes SixtJul 6, 2009
  12. 1/7 MinGW: truncate exit()'s argument to lowest 8 bitsJohannes Sixt, Jul 5, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.