Open pfw opened 1 year ago
A single line example of what I'm looking to achieve - STDIN input to a process which then writes back out STDOUT (and/or STDERR)
echo "this and that" | docker run -i busybox sh -c "sleep 5; cat -"
This is actually a known limitation of libkrun. STDIN/STDOUT are tied to the emulated virtio-console, and their interactions are designed with interactive TTY sessions in mind, to the point of tying the lifetime of the VM to STDIN.
We need to revamp this mechanism to properly use non-TTY uses, such as the one you're describing. I'll create an Issue to track this progress.
Thanks @slp - good to know that is behaving as expected even if not ideal for our current use case.
I'm trying to understand the handling of STDIN and am a little lost. From the comments in libkrun.h where it says
I'm assuming that something is being done with the STDIN FD of the chroot_vm and therefore the target process STDIN and it looks from running a process with chroot_vm as a subprocess via python that STDIN is getting closed and reopened somehow.
In these lsof listings I can see the parent (75590) has opened PIPEs to the subprocess and STDOUT/STDERR remain open and connected to the chroot_vm child (75622) but the child has FD 0 as a PIPE with no connection back to the parent.
Is this expected? If so what is the recommended way to drive a subprocess where you need to feed input to it's STDIN?