Skip to content

Conversation

@jmarshall
Copy link
Member

Similar to samtools/samtools#1909, this is a companion pull request to samtools/htslib#1665. Now that hts_open("-", "w") / hts_close() no longer actually closes stdout. Close it explicitly at the end of main() when a subcommand may have written to stdout, so there is an opportunity to detect I/O errors in previously-uncommitted writes.

Ignore EBADF as other code may have already closed stdout, e.g., either particular subcommands or when (dynamically) linked against an older version of HTSlib.

Also trivially: include <strings.h> where needed to ensure strcasecmp() et al are declared. (<strings.h> is often a byproduct of <string.h> but POSIX doesn't require that.)

Since PR samtools/htslib#1665, hts_open("-", "w") / hts_close() no longer
actually closes stdout. Close it at the end of main() so there is an
opportunity to detect I/O errors in previously-uncommitted writes.

Ignore EBADF as other code may have already closed stdout, e.g., either
particular subcommands or when (dynamically) linked against an older
version of HTSlib.
Other source files that use strcase*() functions #include <strings.h>
themselves, so do so for this source file too. (<strings.h> is often
a byproduct of <string.h> but POSIX doesn't require that.)
@jmarshall jmarshall marked this pull request as draft November 27, 2023 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant