Skip to content

Commit

Permalink
Flush stdout/stderr to fix issues with bcftools query not returning a…
Browse files Browse the repository at this point in the history
…ny output
  • Loading branch information
robertaboukhalil committed Aug 18, 2021
1 parent 0cf10b9 commit b2a12e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ const aioli = {
// Run command. Stdout/Stderr will be saved to "tool.stdout"/"tool.stderr" (see "print" and "printErr" above)
tool.module.callMain(args);

// Flush stdout/stderr to make sure we got everything. Otherwise, if use a command like
// `bcftools query -f "%ALT" variants.bcf`, it won't output anything until the next
// invocation of that command!
try {
tool.module.FS.close( tool.module.FS.streams[1] );
tool.module.FS.close( tool.module.FS.streams[2] );
} catch (error) {}
// Re-open stdout/stderr (fix error "error closing standard output: -1")
tool.module.FS.streams[1] = tool.module.FS.open("/dev/stdout", "w");
tool.module.FS.streams[2] = tool.module.FS.open("/dev/stderr", "w");
Expand Down

0 comments on commit b2a12e1

Please sign in to comment.