Skip to content

Avoid nout=0 on last pipe component #90

Open
@lucaswerkmeister

Description

@lucaswerkmeister

This example is somewhat constructed, but:

{{ cat & }} | cat

If you run that command and type something into standard input, nothing will appear on standard output. I think this is because dgsh negotiates zero output file descriptors (cat declares n_output_fds=-1), which isn’t very useful for the last component of a pipe.

I’ve also noticed this for my own ja2l program: if you run something like cat /proc/mounts | ./build/libexec/dgsh/ja2l, my program prints:

negotiation resulted in zero outputs, which does not make sense (try piping to cat)

(I added explicit error detection for this case, because otherwise my program crashes – it needs 1—N output fds, there’s just no mechanism to communicate this.)

The problem with this bug report is that this pipeline does print something:

cat /proc/mounts | {{ cat & }} | cat

and so does this one:

cat some_json_file | ./build/libexec/dgsh/ja2l | cat

even though DGSH_DEBUG_LEVEL=3 output in this case also indicates nout=0 for one component (which I would assume to be the final cat). So I might be misunderstanding something here…

TL;DR: if the last pipe component declares nout=-1, perhaps negotiate nout=1 (stdout) instead of nout=0?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions