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

Re: [PATCH] git-daemon server

From
Linus Torvalds <torvalds@osdl.org>
Date
Jun 3, 2005, 21:38 UTC
Message-ID
<Pine.LNX.4.58.0506031410560.1876@ppc970.osdl.org>
In-Reply-To
<1117832172.8970.22.camel@jmcmullan.timesys>
On Fri, 3 Jun 2005, McMullan, Jason wrote:
Show 9 quoted lines
> 
> 1) I used the stdin/stdout stuff as debugging
> 
> 2) It works with xinetd
> 
> 3) Because I can't figure out how to get /bin/sh to give me two pipes
>    that hook together two processes. What I really want:
> 
> ssh user@remote git server --db /my/git.git <|> git server request HEAD

Ok, so a ssh connection _would_ work per se, and the only real issue is the pipe itself is one-directional as done by the shell?

Show 7 quoted lines
> Where 'xxx <|>  yyy' means:
> 
> 	Take process xxx's stdin, hook it to yyy's stdout,
> 	Take process yyy's stdin, hook it to xxx's stdout,
> 	Run till they both die.
> 
> If you know how to do that, I'd be grateful.

Yeah, you're right, you can't do bi-directional piping with shell, and you'd need to do it inside your program. It should be easy enough to do with something like adding a new flag that says "--exec", and when seeing that, doing something like

	if (!strcmp(argv[i], "--exec")) {
		int fd[2][2];
		pid_t pid;
		if (pipe(fd[0]) < 0 || pipe(fd[1]) < 0)
			die("unable to create pipes");
		pid = fork();
		if (pid < 0)
			die("unable to fork exec process");
		if (!pid) {
			dup2(fd[0][0], 0);
			dup2(fd[1][1], 1);
			close_pipes(fd);
			exit(system(argv[i+1]));
		}
		dup2(fd[1][0], 0);
		dup2(fd[0][1], 1);
		close_pipes(fd);
	}
where "close_pipes()" just looks like
	void close_pipes(int *fd)
	{
		int i;
		for (i = 0; i < 3; i++)
			close(fd[i]);
	}

and as usual, the above is totally and utterly untested. And using "system()" is cheezy and does an extra unnecessary fork(), so if you want to, it could be better done with just a "execve(/bin/sh -c 'string')" approach by hand.

Anyway, with _something_ like the above you could do something like
	git-sync --exec "ssh master.kernel.org git-sync" ....
and it would do the obvious thing.
What do you think?
		Linus
Previous: McMullan, JasonNext: Daniel Serpell
Message 10 of 32 in “git-daemon server”
  1. git-daemon serverJason McMullan, Jun 3, 2005
  2. Linus TorvaldsJun 3, 2005
  3. McMullan, JasonJun 3, 2005
  4. Linus TorvaldsJun 3, 2005
  5. McMullan, JasonJun 3, 2005
  6. Linus TorvaldsJun 3, 2005
  7. McMullan, JasonJun 3, 2005
  8. Linus TorvaldsJun 3, 2005
  9. McMullan, JasonJun 3, 2005
  10. Linus TorvaldsJun 3, 2005
  11. Daniel SerpellJun 3, 2005
  12. Jason McMullanJun 5, 2005
  13. Junio C HamanoJun 3, 2005
  14. Linus TorvaldsJun 3, 2005
  15. Junio C HamanoJun 3, 2005
  16. Junio C HamanoJun 3, 2005
  17. Daniel BarkalowJun 3, 2005
  18. Linus TorvaldsJun 3, 2005
  19. Petr BaudisJun 3, 2005
  20. Daniel BarkalowJun 4, 2005
  21. Junio C HamanoJun 5, 2005
  22. Daniel BarkalowJun 5, 2005
  23. Junio C HamanoJun 5, 2005
  24. Daniel BarkalowJun 5, 2005
  25. Linus TorvaldsJun 5, 2005
  26. rename git-rpush and git-rpull to git-ssh-push and git-ssh-pullJunio C Hamano, Jun 5, 2005
  27. Daniel BarkalowJun 5, 2005
  28. Linus TorvaldsJun 5, 2005
  29. rename git-rpush and git-rpull to git-ssh-push and git-ssh-pullJunio C Hamano, Jun 5, 2005
  30. Linus TorvaldsJun 5, 2005
  31. Jason McMullanJun 5, 2005
  32. Linus TorvaldsJun 5, 2005

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.