-
Notifications
You must be signed in to change notification settings - Fork 92
Non interactive input (pipes) makes binaries crash #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I would debug this by running the Looking at the source code for |
Otherwise maybe this could work: https://manpages.ubuntu.com/manpages/trusty/man8/open_init_pty.8.html Or some sort of program that fakes a terminal, I am unfortunately not too familiar with the terminal API. |
Thanks for the quick answer! open_init_pty does work, but using such a program would be kind of a hacky solution for my use-case I'm not familiar with low-level container components, I tried running runc from podman and did not encounter the issue: cat | podman run --runtime /usr/bin/crun -i test
Hello, world! I then tried running runc directly using the same image: Setting up the rootfs and spec mkdir -p bundle/rootfs
cd bundle
crun spec
podman build -t dockerc-program ..
podman export $(podman create dockerc-program) | tar -C rootfs -xf -
crun run dockerc-container Running crun crun run dockerc-container <<< id
2024-12-26T21:36:17.195490Z: tcgetattr: Inappropriate ioctl for device The same error seems to happen, however, I noticed something in the spec generated by crun: {
"ociVersion": "1.0.0",
"process": {
"terminal": true,
"user": {
"uid": 0,
"gid": 0
},
"args": [
"sh"
],
...
crun run dockerc-container <<< id
uid=0(root) gid=0(root) In this example, the /bin/sh binary is ran for testing purposes. Could it be that dockerc tries to run the binary in "terminal" mode by default ? I think the "detection" part can be achieved by using isatty() on fd |
After some troubleshooting, I managed to set the
I don't know if I will be able to present you with a full, clean PR for this, as I likely lack the time and technical knowledge, it is also the first time i've written any line of zig ever |
Great work, thanks for debugging this! |
I'm using dockerc for a simple program that takes input via STDIN.
It works well when passing data interactively (i.e: the user entering it directly in their terminal), but when using any non-interactive inputs, the dockerc generated binaries crash instantly.
POC
main.c:
Dockerfile:
build.sh
Output
Launching normally (works):
Launching with non-interactive STDIN:
For the record, the normal behaviour is well implemented by
docker run
:I havent included actual user input handling in this example to pinpoint the fact that dockerc binaries crash in all cases, but
docker run -i
handles it correctly too.This crash prevents using dockerc binaries as regular "UNIX-y" command-line utilities.
The text was updated successfully, but these errors were encountered: