{"thread":{"id":"44228","subject":"[PATCH] run-command: fix build on cygwin (stdin is a macro)","startedAt":"2016-10-05T20:19:52Z","lastAt":"2016-10-06T09:58:35Z","messageCount":3,"participants":["Ramsay Jones","Torsten Bögershausen","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"303433","messageId":"f9b6abf6-8305-4a32-29af-765f08fee94b@ramsayjones.plus.com","threadId":"44228","inReplyTo":null,"subject":"[PATCH] run-command: fix build on cygwin (stdin is a macro)","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2016-10-05T20:19:37Z","receivedAt":"2016-10-05T20:19:52Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n\nHi Lars,\n\nCommit 6007c69e (\"run-command: add wait_on_exit\", 04-10-2016), which\nis part of your 'ls/filter-process' branch, causes the build to fail\non cygwin, since 'stdin' is defined as a macro thus:\n\n    #define stdin   (_REENT->_stdin)\n\n(you can probably guess what stdout and stderr look like!) where _REENT\nin turn expands to a function call (__getreent()) which returns a pointer\nto a 'struct _reent', etc., ...\n\nI am not suggesting that you apply this exact patch (stdin_ is not a good\nchoice), but I wanted to show the exact patch I used to get the build to\ncomplete on cygwin.\n\nATB,\nRamsay Jones\n\n run-command.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex 96c54fe..a9dd91a 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -22,7 +22,7 @@ void child_process_clear(struct child_process *child)\n struct child_to_clean {\n \tpid_t pid;\n \tchar *name;\n-\tint stdin;\n+\tint stdin_;\n \tint wait;\n \tstruct child_to_clean *next;\n };\n@@ -37,8 +37,8 @@ static void cleanup_children(int sig, int in_signal)\n \t/* Close the the child's stdin as indicator that Git will exit soon */\n \twhile (p) {\n \t\tif (p->wait)\n-\t\t\tif (p->stdin > 0)\n-\t\t\t\tclose(p->stdin);\n+\t\t\tif (p->stdin_ > 0)\n+\t\t\t\tclose(p->stdin_);\n \t\tp = p->next;\n \t}\n \n@@ -73,12 +73,12 @@ static void cleanup_children_on_exit(void)\n \tcleanup_children(SIGTERM, 0);\n }\n \n-static void mark_child_for_cleanup(pid_t pid, const char *name, int stdin, int wait)\n+static void mark_child_for_cleanup(pid_t pid, const char *name, int stdin_, int wait)\n {\n \tstruct child_to_clean *p = xmalloc(sizeof(*p));\n \tp->pid = pid;\n \tp->wait = wait;\n-\tp->stdin = stdin;\n+\tp->stdin_ = stdin_;\n \tif (name)\n \t\tp->name = xstrdup(name);\n \telse\n@@ -94,7 +94,7 @@ static void mark_child_for_cleanup(pid_t pid, const char *name, int stdin, int w\n }\n \n #ifdef NO_PTHREADS\n-static void mark_child_for_cleanup_no_wait(pid_t pid, const char *name, int timeout, int stdin)\n+static void mark_child_for_cleanup_no_wait(pid_t pid, const char *name, int timeout, int stdin_)\n {\n \tmark_child_for_cleanup(pid, NULL, 0, 0);\n }\n-- \n2.10.0\n"},{"id":"303457","messageId":"7de3821f-5111-47ac-b7e5-20fe1216ba58@web.de","threadId":"44228","inReplyTo":"f9b6abf6-8305-4a32-29af-765f08fee94b@ramsayjones.plus.com","subject":"Re: [PATCH] run-command: fix build on cygwin (stdin is a macro)","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2016-10-06T05:13:59Z","receivedAt":"2016-10-06T05:14:14Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":" >I am not suggesting that you apply this exact patch (stdin_ is not a good\nchoice\n\nHow about fd_stdin ?\n"},{"id":"303474","messageId":"alpine.DEB.2.20.1610061157090.35196@virtualbox","threadId":"44228","inReplyTo":"7de3821f-5111-47ac-b7e5-20fe1216ba58@web.de","subject":"Re: [PATCH] run-command: fix build on cygwin (stdin is a macro)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-10-06T09:58:07Z","receivedAt":"2016-10-06T09:58:35Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 6 Oct 2016, Torsten Bögershausen wrote:\n\n> >I am not suggesting that you apply this exact patch (stdin_ is not a good\n> choice\n> \n> How about fd_stdin ?\n\nBetter: stdin_fd. Why? Prior art:\n\n\t$ git grep -c stdin_fd\n\tbuiltin/remote-ext.c:3\n\n\t$ git grep -c fd_stdin\n\nCiao,\nDscho"}]}