"busy" field is assigned with the command socket descriptor when the terminal is in use. So, use "-1" to disable it.
Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
if (*ttyreq > ttys->max)
goto out;
- if (ttys->tty[*ttyreq - 1].busy)
+ if (ttys->tty[*ttyreq - 1].busy >= 0)
goto out;
/* The requested tty is available. */
}
/* Search for next available tty, fixup index tty1 => [0]. */
- for (ttynum = 1; ttynum <= ttys->max && ttys->tty[ttynum - 1].busy; ttynum++) {
+ for (ttynum = 1; ttynum <= ttys->max && ttys->tty[ttynum - 1].busy >= 0; ttynum++) {
;
}
for (i = 0; i < ttys->max; i++)
if (ttys->tty[i].busy == fd)
- ttys->tty[i].busy = 0;
+ ttys->tty[i].busy = -1;
if (terminal->proxy.busy != fd)
return;