Fix RCons.readCharTimeout() ##cons

This commit is contained in:
pancake 2023-05-17 12:12:32 +02:00
parent 78d8894a9e
commit 11a049f4fe
2 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* radare2 - LGPL - Copyright 2008-2022 - pancake, Jody Frankowski */
/* radare2 - LGPL - Copyright 2008-2023 - pancake, Jody Frankowski */
#include <r_cons.h>
#include <r_util.h>

View File

@ -552,15 +552,17 @@ static int __cons_readchar_w32(ut32 usec) {
}
#endif
R_API int r_cons_readchar_timeout(ut32 usec) {
R_API int r_cons_readchar_timeout(ut32 msec) {
#if R2__UNIX__
struct timeval tv;
fd_set fdset, errset;
FD_ZERO (&fdset);
FD_ZERO (&errset);
FD_SET (0, &fdset);
tv.tv_sec = 0; // usec / 1000;
tv.tv_usec = 1000 * usec;
ut32 secs = msec / 1000;
tv.tv_sec = secs;
ut32 usec = (msec - secs) * 1000;
tv.tv_usec = usec;
r_cons_set_raw (1);
if (select (1, &fdset, NULL, &errset, &tv) == 1) {
return r_cons_readchar ();