{"thread":{"id":"21158","subject":"[PATCH] Fix the exit code of MSVC build scripts on cygwin","startedAt":"2009-10-08T15:33:31Z","lastAt":"2009-10-09T22:04:43Z","messageCount":4,"participants":["Ramsay Jones","Alex Riesen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"124391","messageId":"4ACE064B.5020909@ramsay1.demon.co.uk","threadId":"21158","inReplyTo":null,"subject":"[PATCH] Fix the exit code of MSVC build scripts on cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2009-10-08T15:33:31Z","receivedAt":"2009-10-08T15:33:31Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nDuring an MSVC build on cygwin, the make program did not notice\nwhen the compiler or linker exited with an error. This was caused\nby the scripts exiting with the value returned by system() directly.\n\nOn POSIX-like systems, such as cygwin, the return value of system()\nhas the exit code of the executed command encoded in the first byte\n(ie the value is shifted up by 8 bits). This allows the bottom\n7 bits to contain the signal number of a terminated process, while\nthe eighth bit indicates whether a core-dump was produced. (A value\nof -1 indicates that the command failed to execute.)\n\nThe make program, however, expects the exit code to be encoded in the\nbottom byte. Futhermore, it apparently masks off and ignores anything\nin the upper bytes.\n\nHowever, these scripts are (naturally) intended to be used on the\nwindows platform, where we can not assume POSIX-like semantics from\na perl implementation (eg ActiveState). So, in general, we can not\nassume that shifting the return value right by eight will get us\nthe exit code.\n\nIn order to improve portability, we assume that a zero return from\nsystem() indicates success, whereas anything else indicates failure.\nSince we don't need to know the exact exit code from the compiler\nor linker, we simply exit with 0 (success) or 1 (failure).\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nHi *,\n\nI have tried to be conservative with this patch and, although I can\nconfirm that it works great on cygwin, it should probably be tested\n(and Acked) by someone with an MSYS/Mingw installation.\n(or whatever Marius has installed :)\n\nATB,\nRamsay Jones\n\n compat/vcbuild/scripts/clink.pl |    4 +++-\n compat/vcbuild/scripts/lib.pl   |    4 +++-\n 2 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl\nindex 0ffd59f..26aec61 100644\n--- a/compat/vcbuild/scripts/clink.pl\n+++ b/compat/vcbuild/scripts/clink.pl\n@@ -45,4 +45,6 @@ if ($is_linking) {\n \tpush(@args, @cflags);\n }\n #printf(\"**** @args\\n\");\n-exit system(@args);\n+system(@args) == 0\n+\tor exit 1;\n+exit 0;\ndiff --git a/compat/vcbuild/scripts/lib.pl b/compat/vcbuild/scripts/lib.pl\nindex 68f6644..c11016d 100644\n--- a/compat/vcbuild/scripts/lib.pl\n+++ b/compat/vcbuild/scripts/lib.pl\n@@ -23,4 +23,6 @@ while (@ARGV) {\n }\n unshift(@args, \"lib.exe\");\n # printf(\"**** @args\\n\");\n-exit system(@args);\n+system(@args) == 0\n+\tor exit 1;\n+exit 0;\n-- \n1.6.4\n"},{"id":"124401","messageId":"81b0412b0910081313x31f72916p6fddd1a23df154df@mail.gmail.com","threadId":"21158","inReplyTo":"4ACE064B.5020909@ramsay1.demon.co.uk","subject":"Re: [PATCH] Fix the exit code of MSVC build scripts on cygwin","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-10-08T20:13:18Z","receivedAt":"2009-10-08T20:13:18Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Thu, Oct 8, 2009 at 17:33, Ramsay Jones <ramsay@ramsay1.demon.co.uk> wrote:\n> diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl\n> index 0ffd59f..26aec61 100644\n> --- a/compat/vcbuild/scripts/clink.pl\n> +++ b/compat/vcbuild/scripts/clink.pl\n> @@ -45,4 +45,6 @@ if ($is_linking) {\n>        push(@args, @cflags);\n>  }\n>  #printf(\"**** @args\\n\");\n> -exit system(@args);\n> +system(@args) == 0\n> +       or exit 1;\n> +exit 0;\n\nexit(system(@args) != 0);\n\nYours looks a little verbose...\n"},{"id":"124429","messageId":"7vy6nl5ag0.fsf@alter.siamese.dyndns.org","threadId":"21158","inReplyTo":"81b0412b0910081313x31f72916p6fddd1a23df154df@mail.gmail.com","subject":"Re: [PATCH] Fix the exit code of MSVC build scripts on cygwin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-09T06:49:03Z","receivedAt":"2009-10-09T06:49:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> On Thu, Oct 8, 2009 at 17:33, Ramsay Jones <ramsay@ramsay1.demon.co.uk> wrote:\n>> diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl\n>> index 0ffd59f..26aec61 100644\n>> --- a/compat/vcbuild/scripts/clink.pl\n>> +++ b/compat/vcbuild/scripts/clink.pl\n>> @@ -45,4 +45,6 @@ if ($is_linking) {\n>>        push(@args, @cflags);\n>>  }\n>>  #printf(\"**** @args\\n\");\n>> -exit system(@args);\n>> +system(@args) == 0\n>> +       or exit 1;\n>> +exit 0;\n>\n> exit(system(@args) != 0);\n>\n> Yours looks a little verbose...\n\nThanks, will queue with a fixup.\n"},{"id":"124581","messageId":"4ACFB37B.8010602@ramsay1.demon.co.uk","threadId":"21158","inReplyTo":"7vy6nl5ag0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Fix the exit code of MSVC build scripts on cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2009-10-09T22:04:43Z","receivedAt":"2009-10-09T22:04:43Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> Alex Riesen <raa.lkml@gmail.com> writes:\n>>> -exit system(@args);\n>>> +system(@args) == 0\n>>> +       or exit 1;\n>>> +exit 0;\n>> exit(system(@args) != 0);\n>>\n>> Yours looks a little verbose...\n> \n> Thanks, will queue with a fixup.\n> \n\nThanks! (Alex and Junio)\n\nI had this as my penultimate version, so I'm happy.\n\n[I changed it to be more explicit about the actual exit values\nreturned by the script. (and thus more verbose :) ]\n\nATB,\nRamsay Jones\n"}]}