rpms/cvs/devel cvs-1.11.22-stdinargs.patch, NONE, 1.1 cvs.spec, 1.63, 1.64
Jiří Moskovčák
jmoskovc at fedoraproject.org
Fri May 29 11:54:33 UTC 2009
Author: jmoskovc
Update of /cvs/extras/rpms/cvs/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26561
Modified Files:
cvs.spec
Added Files:
cvs-1.11.22-stdinargs.patch
Log Message:
added support for passing arguments thru stdin (patch from arozansk at redhat.com)
Resolves: #501942
cvs-1.11.22-stdinargs.patch:
--- NEW FILE cvs-1.11.22-stdinargs.patch ---
--- cvs-1.11.22.orig/src/cvs.h 2008-09-09 13:46:07.000000000 -0400
+++ cvs-1.11.22/src/cvs.h 2008-09-09 13:46:13.000000000 -0400
@@ -695,6 +695,8 @@ void sleep_past PROTO ((time_t desttime)
#define RUN_STDOUT_APPEND 0x0004 /* append to stdout, don't truncate */
#define RUN_STDERR_APPEND 0x0008 /* append to stderr, don't truncate */
#define RUN_SIGIGNORE 0x0010 /* ignore interrupts for command */
+#define RUN_PIPE 0x0020 /* pass the arguments by stdin instead
+ * as arguments */
#define RUN_TTY (char *)0 /* for the benefit of lint */
void run_add_arg_p PROTO ((int *, size_t *, char ***, const char *s));
--- cvs-1.11.22.orig/src/run.c 2005-10-03 16:31:12.000000000 -0400
+++ cvs-1.11.22/src/run.c 2008-09-09 13:49:15.000000000 -0400
@@ -123,6 +123,8 @@ run_exec (stin, stout, sterr, flags)
int rc = -1;
int rerrno = 0;
int pid, w;
+ int pipefd[2];
+ char *run_argv2[3] = { NULL, "-", NULL };
#ifdef POSIX_SIGNALS
sigset_t sigset_mask, sigset_omask;
@@ -163,7 +165,26 @@ run_exec (stin, stout, sterr, flags)
mode_out |= ((flags & RUN_STDOUT_APPEND) ? O_APPEND : O_TRUNC);
mode_err |= ((flags & RUN_STDERR_APPEND) ? O_APPEND : O_TRUNC);
- if (stin && (shin = open (stin, O_RDONLY)) == -1)
+ if (*(run_argv[0]) == '|')
+ {
+ char *buf;
+
+ if (pipe(pipefd) == -1) {
+ rerrno = errno;
+ error (0, errno, "unable to open pipe");
+ goto out0;
+ }
+ flags |= RUN_PIPE;
+ shin = pipefd[0];
+ buf = strdup(run_argv[0] + 1); /* skip '|' */
+ if (buf == NULL) {
+ rc = ENOMEM;
+ error (0, errno, "unable to allocate memory");
+ goto out1;
+ }
+ run_argv2[0] = buf;
+ }
+ else if (stin && (shin = open (stin, O_RDONLY)) == -1)
{
rerrno = errno;
error (0, errno, "cannot open %s for reading (prog %s)",
@@ -239,8 +260,14 @@ run_exec (stin, stout, sterr, flags)
#endif
/* dup'ing is done. try to run it now */
- (void) execvp (run_argv[0], run_argv);
- error (0, errno, "cannot exec %s", run_argv[0]);
+ if (flags & RUN_PIPE) {
+ close(pipefd[1]);
+ (void) execvp (run_argv2[0], run_argv2);
+ error (0, errno, "cannot exec %s", run_argv2[0]);
+ } else {
+ (void) execvp (run_argv[0], run_argv);
+ error (0, errno, "cannot exec %s", run_argv[0]);
+ }
_exit (127);
}
else if (pid == -1)
@@ -283,6 +310,39 @@ run_exec (stin, stout, sterr, flags)
#endif
#endif
+ /* write all the arguments in the stdout if requested */
+ if (flags & RUN_PIPE) {
+ int size, s;
+
+ close(pipefd[0]);
+ for (w = 0; run_argv[w] != NULL; w++) {
+ size = strlen(run_argv[w]);
+ s = 0;
+ while (s < size) {
+ rc = write(pipefd[1], run_argv[w] + s, size - s);
+ if (rc < 0 && errno != EINTR) {
+ /* all other cases we'll just fail */
+ rerrno = errno;
+ error (0, errno, "unable to write to the application's stdin %s",
+ run_argv2[0]);
+ goto wait_for_process;
+ } else if (rc > 0)
+ s += rc;
+ }
+ do {
+ rc = write(pipefd[1], "\n", 1);
+ if (rc < 0 && errno != EINTR) {
+ rerrno = errno;
+ error (0, errno, "unable to write to the application's stdin %s",
+ run_argv2[0]);
+ goto wait_for_process;
+ }
+ } while (rc != 1);
+ }
+wait_for_process:
+ close(pipefd[1]);
+ pipefd[1] = -1;
+ }
/* wait for our process to die and munge return status */
#ifdef POSIX_SIGNALS
while ((w = waitpid (pid, &status, 0)) == -1 && errno == EINTR)
@@ -356,7 +416,14 @@ run_exec (stin, stout, sterr, flags)
* relative to the protocol pipe
*/
cvs_flushout();
+ if (flags & RUN_PIPE)
+ free(run_argv2[0]);
out1:
+ if (flags & RUN_PIPE) {
+ shin = -1;
+ if (pipefd[1] != -1)
+ close(pipefd[1]);
+ }
if (stin)
(void) close (shin);
Index: cvs.spec
===================================================================
RCS file: /cvs/extras/rpms/cvs/devel/cvs.spec,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -p -r1.63 -r1.64
--- cvs.spec 8 Apr 2009 14:56:15 -0000 1.63
+++ cvs.spec 29 May 2009 11:54:02 -0000 1.64
@@ -6,7 +6,7 @@
Summary: A version control system
Name: cvs
Version: 1.11.23
-Release: 4%{?dist}
+Release: 5%{?dist}
License: GPL+
Group: Development/Tools
Source0: ftp://ftp.gnu.org/non-gnu/cvs/source/stable/%{version}/cvs-%{version}.tar.bz2
@@ -45,6 +45,7 @@ Patch15: cvs-1.11.21-sort.patch
Patch17: cvs-1.11.22-ipv6-proxy.patch
#Patch18: cvs-1.11.22-diff-rm.patch
Patch19: cvs-1.11.23-getline64.patch
+Patch20: cvs-1.11.22-stdinargs.patch
%description
@@ -86,6 +87,7 @@ release.
%patch17 -p1 -b .ipv6
#%patch18 -p1 -b .diff-rm
%patch19 -p1 -b getline64
+%patch20 -p1 -b .stdinargs
# Apply a patch to the generated files, OR
# run autoreconf and require autoconf >= 2.58, automake >= 1.7.9
@@ -163,6 +165,10 @@ exit 0
%{_sysconfdir}/profile.d/*
%changelog
+* Mon May 25 2009 Jiri Moskovcak <jmoskovc at redhat.com> - 1.11.23.5
+- added support for passing arguments thru stdin (patch from arozansk at redhat.com)
+- Resolves: #501942
+
* Wed Apr 08 2009 Adam Jackson <ajax at redhat.com> 1.11.23-4
- Disable krb4 support to fix F12 buildroots.
More information about the scm-commits
mailing list