Skip to content

Commit 83b4239

Browse files
xiaoxiang781216acassis
authored andcommitted
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>
1 parent ae66695 commit 83b4239

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

arch/sim/src/sim/posix/sim_hostuart.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void restoremode(void)
9595

9696
void host_uart_start(void)
9797
{
98-
int flags;
98+
int nonblock = 1;
9999

100100
/* Get the current stdin terminal mode */
101101

@@ -105,21 +105,13 @@ void host_uart_start(void)
105105

106106
setrawmode(0);
107107

108-
flags = host_uninterruptible(fcntl, 0, F_GETFL, 0);
109-
if (flags > 0)
110-
{
111-
host_uninterruptible_no_return(fcntl, 0, F_SETFL, flags | O_NONBLOCK);
112-
}
108+
host_uninterruptible_no_return(ioctl, 0, FIONBIO, &nonblock);
113109

114110
/* Set stdout to non-blocking to prevent write(1, ...) from blocking
115111
* the entire sim process when the host pipe buffer is full.
116112
*/
117113

118-
flags = host_uninterruptible(fcntl, 1, F_GETFL, 0);
119-
if (flags > 0)
120-
{
121-
host_uninterruptible_no_return(fcntl, 1, F_SETFL, flags | O_NONBLOCK);
122-
}
114+
host_uninterruptible_no_return(ioctl, 1, FIONBIO, &nonblock);
123115

124116
/* Restore the original terminal mode before exit */
125117

0 commit comments

Comments
 (0)