Currently the vi editor will fail with "vi: can't read user input" in failsafe mode because procd patches all stdio channels to the same descriptor, then sets nonblocking mode on stderr which causes stdin to end up in nonblocking mode as well.
Programs like "vi" expect read operations on stdin to block when no input is available, causing them to fail if read() unexpectedly yields EAGAIN errors. This patch series addresses the problem by introducing common utility functions to deal with stdio redirections. The implementation will assign a distinct descriptor to each i/o channel and use the proper mode (O_WRONLY/O_RDONLY) when setting them up. Call sites touching stdin, stdout and stderr are converted to the common utility functions and error logging is added where appropriate. While we're at it we also fix a file descriptor leak caused by a missing close() after a creat() call in preinit.c Jo-Philipp Wich (5): utils: add patch_fd() and patch_stdio() helpers initd: use patch_stdio() for early console setup initd: use patch_stdio() for kmodloader stdio redirection inittab: use patch_stdio() for stdio redirection initd: fix descriptor leak initd/early.c | 18 +++++------------- initd/init.c | 14 +++----------- initd/preinit.c | 9 ++++++++- inittab.c | 12 ++---------- utils/utils.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ utils/utils.h | 3 +++ 6 files changed, 75 insertions(+), 35 deletions(-) -- 2.1.4 _______________________________________________ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev