Skip to content

Redirect "out+err" hangs #8565

@michael-swan

Description

@michael-swan

Describe the bug

If you have a process which outputs lots of logging on stdout and stderr, the nu docs say you could do "cmd out+err> [filename]" to pipe both into a file. This hangs and when you kill the process it ends up having around 64KB's of data in the output file flushed at the end, every time.

How to reproduce

  1. Create a program called foo.c:
#include <stdio.h>

int main() {
	// Should emit 1MiB on stderr
	for (int i = 0; i < (1024 * 1024) / 16; i++) {
		fprintf(stderr, "0123456789ABCDE\n");
	}
}
  1. Compile with gcc foo.c
  2. Run with ./a.out out+err> /tmp/foo.txt
  3. Observe that it hangs, exit and observe /tmp/foo.txt filesize
  4. Run with ./a.out err> /tmp/foo.txt
  5. Observe that it doesn't hang and observe /tmp/foo.txt filesize

Expected behavior

It shouldn't hang when mixing out+err> pipe form and should populate the file the same as in the err> pipe case.

Screenshots

No response

Configuration

key value
version 0.77.1
branch
commit_hash 0120e40
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.66.1 (90743e729 2023-01-10)
rust_channel 1.66.1-x86_64-unknown-linux-gnu
cargo_version cargo 1.66.1 (ad779e08b 2023-01-10)
build_time 2023-03-17 05:17:52 +00:00
build_rust_channel release
features default, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:redirection-pipeAll related to redirection to files or more complex pipelines with STDERRcategory:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions