Clear O_NONBLOCK flag on stdin before exiting.
Clear O_NONBLOCK flag on stdin before exiting, ensuring read can access it. Otherwise if fbterm is running in a non-interactive environment, e.g, when invoked with sudo -i, causing the read command to fail when trying to access the terminal input. How to reproduce this issue: E.g., a script called myfbterm.sh is
#!/bin/bash
fbterm -- ls -al /tmp
echo -n "press any key"
read
Run it with:
sudo -i ./myfbterm.sh
It gave this error:
press any key/tmp/myfbterm.sh: line 4: read: read error: 0: Resource temporarily unavailable
This is due to fbterm doesn't properly pass the terminal input to the read command, especially under sudo -i.
Edited by Steven Shiau