summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 64224ca)
raw | patch | inline | side by side (parent: 64224ca)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Thu, 8 Dec 2005 02:04:38 +0000 (21:04 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 8 Dec 2005 05:05:39 +0000 (21:05 -0800) |
When calling post-update hook, don't leave stdin and stdout connected to
the pushing connection.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
the pushing connection.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
receive-pack.c | patch | blob | history | |
run-command.c | patch | blob | history | |
run-command.h | patch | blob | history |
diff --git a/receive-pack.c b/receive-pack.c
index 18735061206a813d523fdf29dd3e5b06899f1a1d..cbe37e72391c5f22fb21a48fe64232c212ed8709 100644 (file)
--- a/receive-pack.c
+++ b/receive-pack.c
argc++;
}
argv[argc] = NULL;
- run_command_v(argc, argv);
+ run_command_v_opt(argc, argv, RUN_COMMAND_NO_STDIO);
}
/*
diff --git a/run-command.c b/run-command.c
index 5787a5095548c6530a4d987705a3189ed57356c4..8bf5922fc3b30d06ca7336a8df18a12c389c8681 100644 (file)
--- a/run-command.c
+++ b/run-command.c
#include "run-command.h"
#include <sys/wait.h>
-int run_command_v(int argc, char **argv)
+int run_command_v_opt(int argc, char **argv, int flags)
{
pid_t pid = fork();
if (pid < 0)
return -ERR_RUN_COMMAND_FORK;
if (!pid) {
+ if (flags & RUN_COMMAND_NO_STDIO) {
+ int fd = open("/dev/null", O_RDWR);
+ dup2(fd, 0);
+ dup2(fd, 1);
+ close(fd);
+ }
execvp(argv[0], (char *const*) argv);
die("exec %s failed.", argv[0]);
}
}
}
+int run_command_v(int argc, char **argv)
+{
+ return run_command_v_opt(argc, argv, 0);
+}
+
int run_command(const char *cmd, ...)
{
int argc;
va_end(param);
if (MAX_RUN_COMMAND_ARGS <= argc)
return error("too many args to run %s", cmd);
- return run_command_v(argc, argv);
+ return run_command_v_opt(argc, argv, 0);
}
diff --git a/run-command.h b/run-command.h
index 5ee0972241030d2f6d87a465c4726e6cc3ab803a..2469eeaefbc19424d5ec61f173cc17b68a183bc5 100644 (file)
--- a/run-command.h
+++ b/run-command.h
ERR_RUN_COMMAND_WAITPID_NOEXIT,
};
+#define RUN_COMMAND_NO_STDIO 1
+
+int run_command_v_opt(int argc, char **argv, int opt);
int run_command_v(int argc, char **argv);
int run_command(const char *cmd, ...);