aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2009-08-03 09:06:35 +0000
committerDaniel Stenberg <daniel@haxx.se>2009-08-03 09:06:35 +0000
commit9d03dd7fb83371b01997fe8e6bc000ce6d56f8d4 (patch)
treef124a3d78dead2aa2df8c709a466fe605f649689 /src/main.c
parent781b82baf5e481964d67971848e4f363915ef789 (diff)
respect error code from ftruncate(), mentioned by Peter Sylvester
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index c7669ad11..ddca73322 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4991,7 +4991,14 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
fflush(outs.stream);
/* truncate file at the position where we started appending */
#ifdef HAVE_FTRUNCATE
- ftruncate( fileno(outs.stream), outs.init);
+ if(ftruncate( fileno(outs.stream), outs.init)) {
+ /* when truncate fails, we can't just append as then we'll
+ create something strange, bail out */
+ if(!config->mute)
+ fprintf(config->errors,
+ "failed to truncate, exiting\n");
+ break;
+ }
/* now seek to the end of the file, the position where we
just truncated the file in a large file-safe way */
fseek(outs.stream, 0, SEEK_END);