Skip to content

Commit

Permalink
tool: dump headers even if file is write-only
Browse files Browse the repository at this point in the history
The fixes in #10079 brought a (seemingly unrelated) change of open mode
from `wb`/`ab` to `wb+`/`ab+` for the headerfile. This makes it no
longer possible to write the header file to e.g. a pipe, like:

    curl -D >(grep ...) file:///dev/null

Which presently results in `Warning: Failed to open /dev/fd/63`

See #10079
Closes #XXXX
  • Loading branch information
algorythmic committed Mar 4, 2023
1 parent e135bc9 commit f03f01c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tool_operate.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,11 +983,11 @@ static CURLcode single_transfer(struct GlobalConfig *global,
* for every transfer.
*/
if(!per->prev || per->prev->config != config) {
newfile = fopen(config->headerfile, "wb+");
newfile = fopen(config->headerfile, "wb");
if(newfile)
fclose(newfile);
}
newfile = fopen(config->headerfile, "ab+");
newfile = fopen(config->headerfile, "ab");

if(!newfile) {
errorf(global, "Failed to open %s\n", config->headerfile);
Expand Down

0 comments on commit f03f01c

Please sign in to comment.