Multiple stdout htsFile's result in no output

Open
#611 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c

Research direction

Start by compiling and running the minimal example using bcf_open, bcf_hdr_write, and hts_close from htslib/vcf.h, first with and then without the second open. Trace how repeated stdout htsFile instances are handled and verify that closing and reopening stdout still produces the expected VCF output.

Written by the indexing model from the issue text.

Description

It appears it's only possible to create a single working stdout htsFile instance in a single execution, even if only one is actually open. Writing to a second instance results in no output to stdout. For example, uncommenting the two lines below results in no output to stdout:

#include "htslib/vcf.h"

int main()
{
    auto bcf = bcf_open("-", "[w]");
    // hts_close(bcf);
    // bcf = bcf_open("-", "[w]");
    const auto header = bcf_hdr_init("w");
    bcf_hdr_write(bcf, header);
    hts_close(bcf);
    bcf_hdr_destroy(header);
}
Dominant language
C
Stars
950
Forks
475
Avg merge
3d 13h
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from samtools/htslib

All issues in samtools/htslib

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.