| 1137 | } |
| 1138 | |
| 1139 | static void |
| 1140 | tty_rel_free(struct tty *tp) |
| 1141 | { |
| 1142 | struct cdev *dev; |
| 1143 | |
| 1144 | tty_assert_locked(tp); |
| 1145 | |
| 1146 | #define TF_ACTIVITY (TF_GONE|TF_OPENED|TF_HOOK|TF_OPENCLOSE) |
| 1147 | if (tp->t_sessioncnt != 0 || (tp->t_flags & TF_ACTIVITY) != TF_GONE) { |
| 1148 | /* TTY is still in use. */ |
| 1149 | tty_unlock(tp); |
| 1150 | return; |
| 1151 | } |
| 1152 | |
| 1153 | /* Stop asynchronous I/O. */ |
| 1154 | funsetown(&tp->t_sigio); |
| 1155 | |
| 1156 | /* TTY can be deallocated. */ |
| 1157 | dev = tp->t_dev; |
| 1158 | tp->t_dev = NULL; |
| 1159 | tty_unlock(tp); |
| 1160 | |
| 1161 | if (dev != NULL) { |
| 1162 | sx_xlock(&tty_list_sx); |
| 1163 | TAILQ_REMOVE(&tty_list, tp, t_list); |
| 1164 | tty_list_count--; |
| 1165 | sx_xunlock(&tty_list_sx); |
| 1166 | destroy_dev_sched_cb(dev, tty_dealloc, tp); |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | void |
| 1171 | tty_rel_pgrp(struct tty *tp, struct pgrp *pg) |
no test coverage detected