Skip to content

Commit d99193e

Browse files
committed
[update] fix finsh bug
1 parent 75a7cb6 commit d99193e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

components/finsh/shell.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,19 @@ int finsh_getchar(void)
162162
RT_ASSERT(shell != RT_NULL);
163163

164164
device = shell->device;
165-
if (device == RT_NULL)
166-
{
167-
return -1; /* EOF */
168-
}
169165

170166
while (rt_device_read(device, -1, &ch, 1) != 1)
167+
{
171168
rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER);
172-
169+
if (shell->device != device)
170+
{
171+
device = shell->device;
172+
if (device == RT_NULL)
173+
{
174+
return -1;
175+
}
176+
}
177+
}
173178
return ch;
174179
#endif /* RT_USING_POSIX_STDIO */
175180
#else

0 commit comments

Comments
 (0)