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

[PATCH] run-command: fix build on cygwin (stdin is a macro)

From
Ramsay Jones <ramsay@ramsayjones.plus.com>
Date
Oct 5, 2016, 20:19 UTC
Message-ID
<f9b6abf6-8305-4a32-29af-765f08fee94b@ramsayjones.plus.com>
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
Hi Lars,

Commit 6007c69e ("run-command: add wait_on_exit", 04-10-2016), which is part of your 'ls/filter-process' branch, causes the build to fail on cygwin, since 'stdin' is defined as a macro thus:

    #define stdin   (_REENT->_stdin)

(you can probably guess what stdout and stderr look like!) where _REENT in turn expands to a function call (__getreent()) which returns a pointer to a 'struct _reent', etc., ...

I am not suggesting that you apply this exact patch (stdin_ is not a good choice), but I wanted to show the exact patch I used to get the build to complete on cygwin.

ATB, Ramsay Jones

 run-command.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/run-command.c b/run-command.c
index 96c54fe..a9dd91a 100644
--- a/run-command.c
+++ b/run-command.c
@@ -22,7 +22,7 @@ void child_process_clear(struct child_process *child)
 struct child_to_clean {
 	pid_t pid;
 	char *name;
-	int stdin;
+	int stdin_;
 	int wait;
 	struct child_to_clean *next;
 };
@@ -37,8 +37,8 @@ static void cleanup_children(int sig, int in_signal)
 	/* Close the the child's stdin as indicator that Git will exit soon */
 	while (p) {
 		if (p->wait)
-			if (p->stdin > 0)
-				close(p->stdin);
+			if (p->stdin_ > 0)
+				close(p->stdin_);
 		p = p->next;
 	}
 
@@ -73,12 +73,12 @@ static void cleanup_children_on_exit(void)
 	cleanup_children(SIGTERM, 0);
 }
 
-static void mark_child_for_cleanup(pid_t pid, const char *name, int stdin, int wait)
+static void mark_child_for_cleanup(pid_t pid, const char *name, int stdin_, int wait)
 {
 	struct child_to_clean *p = xmalloc(sizeof(*p));
 	p->pid = pid;
 	p->wait = wait;
-	p->stdin = stdin;
+	p->stdin_ = stdin_;
 	if (name)
 		p->name = xstrdup(name);
 	else
@@ -94,7 +94,7 @@ static void mark_child_for_cleanup(pid_t pid, const char *name, int stdin, int w
 }
 
 #ifdef NO_PTHREADS
-static void mark_child_for_cleanup_no_wait(pid_t pid, const char *name, int timeout, int stdin)
+static void mark_child_for_cleanup_no_wait(pid_t pid, const char *name, int timeout, int stdin_)
 {
 	mark_child_for_cleanup(pid, NULL, 0, 0);
 }
-- 
2.10.0
Next: Torsten Bögershausen
Message 1 of 3 in “run-command: fix build on cygwin (stdin is a macro)”
  1. run-command: fix build on cygwin (stdin is a macro)Ramsay Jones, Oct 5, 2016
  2. Torsten BögershausenOct 6, 2016
  3. Johannes SchindelinOct 6, 2016

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.