**Describe what's wrong**
Query in clickhouse-client may fail with options `--send_logs_level=trace --server_logs_file=-` (`--server_logs_file=-` means write server logs to stdout).

**How to reproduce**

```
while true; do clickhouse-client -q "select 1" --send_logs_level=trace --server_logs_file=- >log; done
Code: 75. DB::ErrnoException: Cannot write to file (fd = 1), errno: 14, strerror: Bad address: (in query: select 1). (CANNOT_WRITE_TO_FILE_DESCRIPTOR)

Code: 75. DB::ErrnoException: Cannot write to file (fd = 1), errno: 14, strerror: Bad address: (in query: select 1). (CANNOT_WRITE_TO_FILE_DESCRIPTOR)

Code: 75. DB::ErrnoException: Cannot write to file (fd = 1), errno: 14, strerror: Bad address: (in query: select 1). (CANNOT_WRITE_TO_FILE_DESCRIPTOR)
```

Some queries will fail periodically.


UInt64 compression_level = 3;
                if (query_with_output->compression_level)
                {
                    const auto & compression_level_node = query_with_output->compression_level->as<ASTLiteral &>();
                    bool res = compression_level_node.value.tryGet<UInt64>(compression_level);
                    auto range = getCompressionLevelRange(compression_method);
                    if (!res || compression_level < range.first || compression_level > range.second)
                        throw Exception(
                            ErrorCodes::BAD_ARGUMENTS,
                            "Invalid compression level, must be positive integer in range {}-{}",
                            range.first,
                            range.second);
                }
                out_file_buf = wrapWriteBufferWithCompressionMethod(
                    std::make_unique<WriteBufferFromFile>(out_file, DBMS_DEFAULT_BUFFER_SIZE, O_WRONLY | O_EXCL | O_CREAT),
                    compression_method,
                    compression_level
                );
                if (query_with_output->is_into_outfile_with_stdout)
                {
                    select_into_file_and_stdout = true;
                    out_file_buf = std::make_unique<ForkWriteBuffer>(std::vector<WriteBufferPtr>{std::move(out_file_buf),
                            std::make_shared<WriteBufferFromFileDescriptor>(STDOUT_FILENO)});
                }
                // We are writing to file, so default format is the same as in non-interactive mode.
                if (is_interactive && is_default_format)
                    current_format = "TabSeparated";
            }
            if (query_with_output->format != nullptr)
            {