{"thread":{"id":"7224","subject":"[PATCH 5/7] Use run_command within merge-index","startedAt":"2007-03-12T23:00:21Z","lastAt":"2007-03-12T23:00:21Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"36970","messageId":"20070312230021.GE16840@spearce.org","threadId":"7224","inReplyTo":null,"subject":"[PATCH 5/7] Use run_command within merge-index","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-03-12T23:00:21Z","receivedAt":"2007-03-12T23:00:21Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Maybe unnecessary as the merge-index utility may go away in the\nfuture, but its currently here, its shorter to use run_command,\nand probably will help the MinGW port out.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n merge-index.c |   23 +++++------------------\n 1 files changed, 5 insertions(+), 18 deletions(-)\n\ndiff --git a/merge-index.c b/merge-index.c\nindex 7027d78..6df4394 100644\n--- a/merge-index.c\n+++ b/merge-index.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"run-command.h\"\n \n static const char *pgm;\n static const char *arguments[8];\n@@ -7,24 +8,10 @@ static int err;\n \n static void run_program(void)\n {\n-\tpid_t pid = fork();\n-\tint status;\n-\n-\tif (pid < 0)\n-\t\tdie(\"unable to fork\");\n-\tif (!pid) {\n-\t\texeclp(pgm, arguments[0],\n-\t\t\t    arguments[1],\n-\t\t\t    arguments[2],\n-\t\t\t    arguments[3],\n-\t\t\t    arguments[4],\n-\t\t\t    arguments[5],\n-\t\t\t    arguments[6],\n-\t\t\t    arguments[7],\n-\t\t\t    NULL);\n-\t\tdie(\"unable to execute '%s'\", pgm);\n-\t}\n-\tif (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) {\n+\tstruct child_process child;\n+\tmemset(&child, 0, sizeof(child));\n+\tchild.argv = arguments;\n+\tif (run_command(&child)) {\n \t\tif (one_shot) {\n \t\t\terr++;\n \t\t} else {\n-- \n1.5.0.3.985.gcf0b4\n"}]}