11.6. syscall emulation mode program stdin
The following work on both QEMU and gem5 as of LKMC 99d6bc6bc19d4c7f62b172643be95d9c43c26145 + 1. Interactive input:
./run --userland userland/c/getchar.c
Source: userland/c/getchar.c
A line of type should show:
enter a character:
and after pressing say a
and Enter, we get:
you entered: a
Note however that due to QEMU user mode does not show stdout immediately we don’t really see the initial enter a character
line.
Non-interactive input from a file by forwarding emulators stdin implicitly through our Python scripts:
printf a > f.tmp ./run --userland userland/c/getchar.c < f.tmp
Input from a file by explicitly requesting our scripts to use it via the Python API:
printf a > f.tmp ./run --emulator gem5 --userland userland/c/getchar.c --stdin-file f.tmp
This is especially useful when running tests that require stdin input.