Skip to content

Commit 21f43ba

Browse files
committed
unix/modtermios: tcsetattr: If 0 passed for "when" param, treat as TCSANOW.
As we dn't export constants for TCSANOW, etc., zero makes a good "don't care" param, and now it will work also under Android Bionic and any other libc.
1 parent 3c9c368 commit 21f43ba

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

unix/modtermios.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ STATIC mp_obj_t mod_termios_tcsetattr(mp_obj_t fd_in, mp_obj_t when_in, mp_obj_t
7171
struct termios term;
7272
int fd = mp_obj_get_int(fd_in);
7373
int when = mp_obj_get_int(when_in);
74+
if (when == 0) {
75+
// We don't export TCSANOW and friends to save on code space. Then
76+
// common lazy sense says that passing 0 should be godo enough, and
77+
// it is e.g. for glibc. But for other libc's it's not, so set just
78+
// treat 0 as defauling to TCSANOW.
79+
when = TCSANOW;
80+
}
81+
7482
assert(MP_OBJ_IS_TYPE(attrs_in, &mp_type_list));
7583
mp_obj_list_t *attrs = attrs_in;
7684

0 commit comments

Comments
 (0)