- if (cur_term == 0
- || SET_TTY(cur_term->Filedes, buf) != 0)
- return(ERR);
- TR(TRACE_BITS,("_nc_set_tty_mode: %s", _nc_tracebits()));
- return (OK);
+ int result = OK;
+
+ if (buf == 0) {
+ result = ERR;
+ } else {
+ if (cur_term == 0) {
+ result = ERR;
+ } else {
+ for (;;) {
+ if (SET_TTY(cur_term->Filedes, buf) != 0) {
+ if (errno == EINTR)
+ continue;
+ if ((errno == ENOTTY) && (SP != 0))
+ SP->_notty = TRUE;
+ result = ERR;
+ }
+ break;
+ }
+ }
+ TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
+ cur_term ? cur_term->Filedes : -1,
+ _nc_trace_ttymode(buf)));
+ }
+ return (result);