mirror of
https://github.com/apache/nuttx.git
synced 2026-09-03 23:52:58 +00:00
arch/sim: switch nonblock setup to ioctl FIONBIO
Update host_uart_start() to set stdin/stdout nonblocking via ioctl. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
ae666954e6
commit
83b4239e1d
1 changed files with 3 additions and 11 deletions
|
|
@ -95,7 +95,7 @@ static void restoremode(void)
|
|||
|
||||
void host_uart_start(void)
|
||||
{
|
||||
int flags;
|
||||
int nonblock = 1;
|
||||
|
||||
/* Get the current stdin terminal mode */
|
||||
|
||||
|
|
@ -105,21 +105,13 @@ void host_uart_start(void)
|
|||
|
||||
setrawmode(0);
|
||||
|
||||
flags = host_uninterruptible(fcntl, 0, F_GETFL, 0);
|
||||
if (flags > 0)
|
||||
{
|
||||
host_uninterruptible_no_return(fcntl, 0, F_SETFL, flags | O_NONBLOCK);
|
||||
}
|
||||
host_uninterruptible_no_return(ioctl, 0, FIONBIO, &nonblock);
|
||||
|
||||
/* Set stdout to non-blocking to prevent write(1, ...) from blocking
|
||||
* the entire sim process when the host pipe buffer is full.
|
||||
*/
|
||||
|
||||
flags = host_uninterruptible(fcntl, 1, F_GETFL, 0);
|
||||
if (flags > 0)
|
||||
{
|
||||
host_uninterruptible_no_return(fcntl, 1, F_SETFL, flags | O_NONBLOCK);
|
||||
}
|
||||
host_uninterruptible_no_return(ioctl, 1, FIONBIO, &nonblock);
|
||||
|
||||
/* Restore the original terminal mode before exit */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue