diff --git a/docs/pv.1 b/docs/pv.1 index dd46415..3e9476f 100644 --- a/docs/pv.1 +++ b/docs/pv.1 @@ -348,7 +348,7 @@ invocations in a single, long, pipeline. Write data to .I FILE rather than standard output. If the file already exists, it will be -overwritten from the start, but not truncated. +truncated. .TP .BI \-L\ RATE \fR,\ \fB\-\-rate-limit\ RATE Limit the transfer to a maximum of diff --git a/docs/pv.1.md b/docs/pv.1.md index 3721016..02ae8da 100644 --- a/docs/pv.1.md +++ b/docs/pv.1.md @@ -260,8 +260,7 @@ that are explicitly switched on will be shown. **-o FILE, \--output FILE** : Write data to *FILE* rather than standard output. If the file - already exists, it will be overwritten from the start, but not - truncated. + already exists, it will be truncated. **-L RATE, \--rate-limit RATE** diff --git a/src/main/main.c b/src/main/main.c index d7e8636..12d5d89 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -306,7 +306,7 @@ int main(int argc, char **argv) if (NULL == opts->output || 0 == strcmp(opts->output, "-")) { pv_state_output_set(state, STDOUT_FILENO, "(stdout)"); } else { - int fd = open(opts->output, O_WRONLY | O_CREAT, 0600); /* flawfinder: ignore */ + int fd = open(opts->output, O_WRONLY | O_CREAT | O_TRUNC, 0600); /* flawfinder: ignore */ /* * flawfinder rationale: the output filename has been * explicitly provided, and in many cases the operator will