summaryrefslogtreecommitdiff
path: root/connect.c
diff options
context:
space:
mode:
authorFranck Bui-Huu <vagabon.xyz@gmail.com>2006-09-12 09:00:13 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-09-13 05:30:32 (GMT)
commitf42a5c4eb0453cd33276e078cd7541b1ef25b2c4 (patch)
tree93a7a3373f67e058bd4f21d3c3f1b69f28fd1c7a /connect.c
parent0f503d77ac9032fbfbd5f3bacafeccbcf408b31f (diff)
downloadgit-f42a5c4eb0453cd33276e078cd7541b1ef25b2c4.zip
git-f42a5c4eb0453cd33276e078cd7541b1ef25b2c4.tar.gz
git-f42a5c4eb0453cd33276e078cd7541b1ef25b2c4.tar.bz2
connect.c: finish_connect(): allow null pid parameter
git_connect() can return 0 if we use git protocol for example. Users of this function don't know and don't care if a process had been created or not, and to avoid them to check it before calling finish_connect() this patch allows finish_connect() to take a null pid. And in that case return 0. [jc: updated function signature of git_connect() with a comment on its return value. ] Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'connect.c')
-rw-r--r--connect.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/connect.c b/connect.c
index 49251f9..c55a20a 100644
--- a/connect.c
+++ b/connect.c
@@ -602,9 +602,15 @@ static void git_proxy_connect(int fd[2], char *host)
#define MAX_CMD_LEN 1024
/*
- * Yeah, yeah, fixme. Need to pass in the heads etc.
+ * This returns 0 if the transport protocol does not need fork(2),
+ * or a process id if it does. Once done, finish the connection
+ * with finish_connect() with the value returned from this function
+ * (it is safe to call finish_connect() with 0 to support the former
+ * case).
+ *
+ * Does not return a negative value on error; it just dies.
*/
-int git_connect(int fd[2], char *url, const char *prog)
+pid_t git_connect(int fd[2], char *url, const char *prog)
{
char *host, *path = url;
char *end;
@@ -748,6 +754,9 @@ int git_connect(int fd[2], char *url, const char *prog)
int finish_connect(pid_t pid)
{
+ if (pid == 0)
+ return 0;
+
while (waitpid(pid, NULL, 0) < 0) {
if (errno != EINTR)
return -1;