Re: ls: write error: Broken pipe

2007-11-11 Thread Dan Nicolaescu
Jim Meyering <[EMAIL PROTECTED]> writes:

  > Dan Nicolaescu <[EMAIL PROTECTED]> wrote:
  > > Jim Meyering <[EMAIL PROTECTED]> writes:
  > >
  > >   > Dan Nicolaescu <[EMAIL PROTECTED]> wrote:
  > >   > ...
  > >   > > I created a new account with /bin/tcsh as a shell, deleted all the 
dot
  > >   > > files in that new account, logged in on a linux console and run the
  > >   > > perl command above.  It prints IGNORE.
  > >   > >
  > >   > > tcsh is: tcsh-6.14-15
  > >   > > perl is: perl-5.8.8-23.fc7
  > >   >
  > >   > Finally!  So that version of tcsh may be at fault.
  > >
  > > I built tcsh-6.15 using the F8 rpm, and the problem still occurs with
  > > that one.
  > >
  > > When you tested this, did you try from an account that uses tcsh as
  > > the shell? Because if I start tcsh from bash things work...
  > 
  > Yes.  I changed my shell to /bin/tcsh and logged in again.
  > 
  > Have you tried on other systems?

I did. I only have access to one F7 system, and that is the one where
I observed the problems. I tried on FC5, no problem there with either
the original tcsh, with the version from F7 recompiled on FC5...

  > Did you already look at /etc/csh.*?
  > Move them aside and try again, just in case.

Tried it, no difference.

  > I'm running out of ideas, but you might want to use oprofile
  > to trace everything from login to your first prompt.
  > Do it twice.  First with /bin/bash as your shell, then with /bin/tcsh.
  > Then compare.

Let's see if I have time to do this before the machine gets upgraded
to F8... 

  > >   > > So I have an older version of tcsh than you do.
  > >   > >
  > >   > > I looked at the src.rpm for my version of tcsh and it has a patch 
that
  > >   > > tinkers with signal handling (not with SIGPIPE, but still...). I'll
  > >   > > try to install your version of tcsh tonight, and maybe build my
  > >   > > version without any patches.
  > >   > >
  > >   > >   > If you could reproduce the problem by starting tcsh manually,
  > >   > >   > I'd suggest debugging (or just using strace) tcsh to see where
  > >   > >   > it's misbehaving.
  > >   > >
  > >   > > What should I look for?
  > >   >
  > >   > In source, look for calls to signal, sigaction, sigprocmask.
  > >   > On recent Linux, they show up in strace output as calls to
  > >   > rt_sigaction and rt_sigprocmask.
  > >
  > > strace did not show anything about SIGPIPE.
  > 
  > I wouldn't expect it to, since you can't reproduce the problem by
  > starting tcsh manually.

If I start tcsh from a tcsh login shell I can reproduce the
problem... 

Thanks!

--dan


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: Segmentation fault, dd or egrep

2007-11-11 Thread Jim Meyering
Zev Weiss <[EMAIL PROTECTED]> wrote:
> I'm trying to recover some data from a disk that was unexpectedly
> reformatted, and am running into a segmentation fault, though it's
> not clear from the output whether it's coming from dd or egrep (hence
> this email being sent to both grep and coreutils).  I'm running the
> following command in bash:
>
> dd if=/dev/sdc | egrep -A 50 -B 50 -a '^[\\\:]\ [^\ \t\n]{1,15}\ \(\
> [A-Za-z0-9\ ]{0,15}\ \-\-\ [A-Za-z0-9\ ]{0,15}\ \)$' > ./outputfile
>
> (Looking for telltale signs of Forth source code.)
>
> It runs for about about two minutes and then fails with a segfault,
> though the console output doesn't tell which process segfaulted.  I'm
> running Fedora 8 x86_64 with Linux kernel version 2.6.23.1-42.fc8 (in
> runlevel 3, for what it's worth).
>
> dd is version 6.9
> egrep is version 2.5.1
> bash is version 3.2.25(1)-release (x86_64-redhat-linux-gnu) [if that's
> of any relevance]

Thanks for taking the time to report it.
Rerun the pipeline, using strace on one command at a time or both.
I'd log egrep's syscalls first:

dd if=/dev/sdc | strace -o egrep-log \
  egrep -A 50 -B 50 -a '^[\\\:]\ [^\ \t\n]{1,15}\ \(\
[A-Za-z0-9\ ]{0,15}\ \-\-\ [A-Za-z0-9\ ]{0,15}\ \)$' > ./outputfile

Then when it segfaults, look at egrep-log.
If that's not helpful, do it for dd instead.

Or easier still, just eliminate dd and the pipeline:

egrep -A 50 -B 50 -a '^[\\\:]\ [^\ \t\n]{1,15}\ \(\
[A-Za-z0-9\ ]{0,15}\ \-\-\ [A-Za-z0-9\ ]{0,15}\ \)$' < /dev/sdc > ./outputfile

if that fails, it's egrep's fault.


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH] Specify output directory for split(1)

2007-11-11 Thread Jim Meyering
Bram Schoenmakers <[EMAIL PROTECTED]> wrote:
> The attached patch adds -t or --target-directory support for split, specifying
> in which directory the split files should go into.
>
> The usecase for this when receiving a big file over a network, but you don't
> have diskspace for the file itself and its splitted version. Now, you can do
> things like this:
>
> cat some_big_file | ssh [EMAIL PROTECTED] split -t /home/bram/tmp/

Thanks for the suggestion and patch,
but you can already do that portably:

  cat some_big_file | ssh [EMAIL PROTECTED] 'sh -c "cd /home/bram/tmp; split"'


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: [PATCH] Specify output directory for split(1)

2007-11-11 Thread Bram Schoenmakers
Op zondag 11 november 2007, schreef Eric Blake:

Hello,

> Thanks for the patch.  However, to be complete, you also need to mention
> it in NEWS, and update the documentation in doc/coreutils.texi.

There you go.

> Also, 
> since this is not a trivial patch, we would need copyright assignment
> before incorporating it.

I tried to understand how to obtain one, but it's not really clear to me. Can 
you, or someone else, give me a little push in the right direction, please?

Kind regards,

-- 
Bram Schoenmakers

What is mind? No matter. What is matter? Never mind.
  (Punch, 1855)
diff --git a/NEWS b/NEWS
index a8434c5..20062fb 100644
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,9 @@ GNU coreutils NEWS-*- outline -*-
   (though the word count will have no real meaning) rather than many
   error messages.
 
+  split accepts a new option: --target-directory (-t). It will write
+  output file to the specified directory.
+
 ** New build options
 
   By default, "make install" no longer attempts to install (or even build) su.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 4c08378..bde3aae 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -2833,6 +2833,12 @@ option.
 @opindex --numeric-suffixes
 Use digits in suffixes rather than lower-case letters.
 
[EMAIL PROTECTED] -t @var{directory}
[EMAIL PROTECTED] --target-directory
[EMAIL PROTECTED] -t
[EMAIL PROTECTED] --target-directory
+Put each output file in a specified @var{directory}
+
 @itemx --verbose
 @opindex --verbose
 Write a diagnostic to standard error just before each output file is opened.
diff --git a/src/split.c b/src/split.c
index 1142b61..814d6a0 100644
--- a/src/split.c
+++ b/src/split.c
@@ -13,7 +13,7 @@
 
You should have received a copy of the GNU General Public License
along with this program.  If not, see .  */
-
+
 /* By [EMAIL PROTECTED], with rms.
 
To do:
@@ -88,6 +88,7 @@ static struct option const longopts[] =
   {"line-bytes", required_argument, NULL, 'C'},
   {"suffix-length", required_argument, NULL, 'a'},
   {"numeric-suffixes", no_argument, NULL, 'd'},
+  {"target-directory", required_argument, NULL, 't'},
   {"verbose", no_argument, NULL, VERBOSE_OPTION},
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
@@ -116,11 +117,12 @@ is -, read standard input.\n\
 Mandatory arguments to long options are mandatory for short options too.\n\
 "), stdout);
   fprintf (stdout, _("\
-  -a, --suffix-length=N   use suffixes of length N (default %d)\n\
-  -b, --bytes=SIZEput SIZE bytes per output file\n\
-  -C, --line-bytes=SIZE   put at most SIZE bytes of lines per output file\n\
-  -d, --numeric-suffixes  use numeric suffixes instead of alphabetic\n\
-  -l, --lines=NUMBER  put NUMBER lines per output file\n\
+  -a, --suffix-length=N  use suffixes of length N (default %d)\n\
+  -b, --bytes=SIZE   put SIZE bytes per output file\n\
+  -C, --line-bytes=SIZE  put at most SIZE bytes of lines per output file\n\
+  -d, --numeric-suffixes use numeric suffixes instead of alphabetic\n\
+  -l, --lines=NUMBER put NUMBER lines per output file\n\
+  -t, --target-directory=DIR  write output files in DIR\n\
 "), DEFAULT_SUFFIX_LENGTH);
   fputs (_("\
   --verbose   print a diagnostic to standard error just\n\
@@ -311,7 +313,7 @@ lines_split (uintmax_t n_lines, char *buf, size_t bufsize)
 }
   while (n_read == bufsize);
 }
-
+
 /* Split into pieces that are as large as possible while still not more
than N_BYTES bytes, and are split on line boundaries except
where lines longer than N_BYTES bytes occur.
@@ -392,6 +394,7 @@ main (int argc, char **argv)
   static char const multipliers[] = "bEGKkMmPTYZ0";
   int c;
   int digits_optind = 0;
+  char *target_directory = NULL;
 
   initialize_main (&argc, &argv);
   program_name = argv[0];
@@ -411,7 +414,7 @@ main (int argc, char **argv)
   /* This is the argv-index of the option we will read next.  */
   int this_optind = optind ? optind : 1;
 
-  c = getopt_long (argc, argv, "0123456789C:a:b:dl:", longopts, NULL);
+  c = getopt_long (argc, argv, "0123456789C:a:b:dl:t:", longopts, NULL);
   if (c == -1)
 	break;
 
@@ -499,6 +502,21 @@ main (int argc, char **argv)
 	  suffix_alphabet = "0123456789";
 	  break;
 
+	case 't':
+	  if (target_directory)
+		  error (EXIT_FAILURE, 0, _("multiple target directories specified"));
+	  else
+	{
+	  struct stat st;
+	  if (stat (optarg, &st) != 0)
+		error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg));
+	  if (! S_ISDIR (st.st_mode))
+		error (EXIT_FAILURE, 0, _("target %s is not a directory"),
+		   quote (optarg));
+	}
+	  target_directory = optarg;
+		break;
+
 	case VERBOSE_OPTION:
 	  verbose = true;
 	  break;
@@ -533,6 +551,11 @@ main (int argc, char **argv)
   if (optind < argc)
 outbase = argv[optind++];
 
+  if (target_directory)
+  {
+out