Bug 9851 - vi: can't read user input if stdin is left in non-blocking mode
Summary: vi: can't read user input if stdin is left in non-blocking mode
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.24.x
Hardware: All Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-28 18:04 UTC by Daniel Starke
Modified: 2017-05-02 18:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
proposed patch (612 bytes, patch)
2017-04-28 18:04 UTC, Daniel Starke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Starke 2017-04-28 18:04:46 UTC
Created attachment 7056 [details]
proposed patch

Using Busybox 1.26.2 I still experience the issue that the vi will not work if some application (mostly those using ncurses) left the standard input in non-blocking mode. Usually there are no means to reset this state with standard commands without restarting the current tty.
The attached file fixes this issue by forcing blocking mode to the standard input at vi start-up.
The patch did not change the size of the vi application in my configuration.

The issue can be reproduced by the following command:
gcc -x c -o nb - <<"_C" && chmod u+rx nb && ./nb && echo abc >a.txt && vi a.txt
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main() {
	/* make standard input non-blocking */
	fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL) | O_NONBLOCK);
	
	return EXIT_SUCCESS;
}
_C
Comment 1 Denys Vlasenko 2017-05-02 18:39:44 UTC
Fixed in git, thanks!