coreutils
[Top][All Lists]
Advanced

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

csplit 'write error' missing errno?


From: Assaf Gordon
Subject: csplit 'write error' missing errno?
Date: Thu, 22 Oct 2015 15:22:26 -0400

Hello,

In a long-running pipeline, we've encountered the following error message with 
'csplit':
  csplit: write error for ‘[FILENAME]`

It is very likely stemming from out-of-disk-space situation, but because there 
was no errno printed, it's hard to know for sure, making troubleshooting a bit 
frustrating.

The error is printed in 'close_output_file()', in response to checking 
'ferror()'.

I wonder if it would be beneficial to add the errno information to the error 
message.

From a cursory look it seems 'close_output_file()' is (almost?) always called 
after
'dump_rest_of_file()' or 'save_line_to_file()' which themselves use 'fwrite()'.

So it could perhaps be assumed that if if 'ferror()' indicates an error on the 
output stream,
then the last operation was fwrite?
The downside is that if my assumption doesn't hold, it could print a misleading 
errno information.

The following patch is a suggestion (not fully tested):

===
diff --git a/src/csplit.c b/src/csplit.c
index d966df5..d2a0228 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -1004,7 +1004,7 @@ close_output_file (void)
     {
       if (ferror (output_stream))
         {
-          error (0, 0, _("write error for %s"), quote (output_filename));
+          error (0, errno, _("write error for %s"), quote (output_filename));
           output_stream = NULL;
           cleanup_fatal ();
         }
===

I'll be able to troubleshoot and provide more information in couple of days.
A more elaborate solution is to save the errno after 'fwrite()' in a variable,
and print that variable. I can send such a patch if that's a better idea.

regards,
 - assaf




reply via email to

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