bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

`cvs up -p FILE' does not detect write failure


From: Jim Meyering
Subject: `cvs up -p FILE' does not detect write failure
Date: Mon, 28 Feb 2005 19:16:14 +0100

Hello,

It looks like no version of CVS detects the write failure
caused by this sort of command:

  $ cvs -Q up -p README > /dev/full
  $

It should do something like this instead:

  $ ./cvs -Q up -p README > /dev/full
  cvs [update aborted]: write error: No space left on device
  [Exit 1]

I've included part of a patch to make it do just that, below.
This changes makes CVS use the closeout module from gnulib.
And that module pulls in a few other modules (fpending, quotearg, etc).
Add to that the fact that running cvs' ./gnulib-update updates
every single file in the m4/ subdirectory, I figured I'd give you
a heads-up first.  What's your policy on updating from Gnulib?

FWIW, with minor changes (to avoid using the gnulib error module),
a cvs binary built with this change and all of the latest gnulib code
passed `make -C src check'.

Also, it might be a little bit cleaner to use atexit (close_stdout),
rather than cleanup_register (close_stdout) -- we certainly don't need
the added SIG_beginCrSect call it provides -- but I opted for consistency.

2005-02-28  Jim Meyering  <jim@meyering.net>

        Detect and report write failure for e.g., cvs up -p FILE > /dev/full
        * main.c: Include "closeout.h".
        (main): Arrange to close standard output upon exit.
        * sanity.sh (close-stdout): New test for this fix.

Index: main.c
===================================================================
RCS file: /cvs/ccvs/src/main.c,v
retrieving revision 1.240
diff -u -p -r1.240 main.c
--- main.c      25 Feb 2005 17:54:03 -0000      1.240
+++ main.c      28 Feb 2005 17:55:18 -0000
@@ -20,6 +20,7 @@
 #include "cvs.h"
 #include "xgethostname.h"
 #include "strftime.h"
+#include "closeout.h"
 
 const char *program_name;
 const char *program_path;
@@ -789,6 +790,7 @@ cause intermittent sandbox corruption.")
        else
 #endif
        {
+           cleanup_register (close_stdout);
            CurDir = xgetcwd ();
             if (CurDir == NULL)
                error (1, errno, "cannot get working directory");
Index: sanity.sh
===================================================================
RCS file: /cvs/ccvs/src/sanity.sh,v
retrieving revision 1.1049
diff -u -p -r1.1049 sanity.sh
--- sanity.sh   26 Feb 2005 17:39:45 -0000      1.1049
+++ sanity.sh   28 Feb 2005 17:55:21 -0000
@@ -1622,6 +1622,7 @@ if test x"$*" = x; then
        # Log messages, error messages.
        tests="${tests} mflag editor env errmsg1 errmsg2 adderrmsg opterrmsg"
        tests="${tests} errmsg3"
+       tests="${tests} close-stdout"
        # Watches, binary files, history browsing, &c.
        tests="${tests} devcom devcom2 devcom3 watch4 watch5"
         tests="${tests} edit-check"
@@ -16254,6 +16255,30 @@ ${CPROG} \[update aborted\]: \*PANIC\* a
 
 
 
+       close-stdout)
+         # Ensure that cvs update -p FILE > /dev/full fails
+         # Perform this test IFF /dev/full is a writable character device.
+         if test -w /dev/full && test -c /dev/full; then
+           mkdir close-stdout
+           cd close-stdout
+           echo a > file
+           dotest close-stdout-1 "$testcvs -Q import -m. closeout X Y" ''
+           dotest close-stdout-2 "$testcvs -Q co closeout" ''
+           # Match either a bare `write error' or
+           # `write error: No space left on device',
+           # since closeout.c can produce both.
+           dotest_fail close-stdout-3 \
+               "${testcvs} -Q update -p closeout/file > /dev/full" \
+               "${CPROG} \[update aborted\]: write error.*"
+
+           dokeep
+           cd ..
+           rm -r close-stdout
+         fi
+         ;;
+
+
+
        adderrmsg)
          # Test some of the error messages the 'add' command can return and
          # their reactions to '-q'.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]