MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ttydev_leave

Function ttydev_leave

freebsd/kern/tty.c:229–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229static void
230ttydev_leave(struct tty *tp)
231{
232
233 tty_assert_locked(tp);
234
235 if (tty_opened(tp) || tp->t_flags & TF_OPENCLOSE) {
236 /* Device is still opened somewhere. */
237 tty_unlock(tp);
238 return;
239 }
240
241 tp->t_flags |= TF_OPENCLOSE;
242
243 /* Remove console TTY. */
244 if (constty == tp)
245 constty_clear();
246
247 /* Drain any output. */
248 if (!tty_gone(tp))
249 tty_drain(tp, 1);
250
251 ttydisc_close(tp);
252
253 /* Free i/o queues now since they might be large. */
254 ttyinq_free(&tp->t_inq);
255 tp->t_inlow = 0;
256 ttyoutq_free(&tp->t_outq);
257 tp->t_outlow = 0;
258
259 knlist_clear(&tp->t_inpoll.si_note, 1);
260 knlist_clear(&tp->t_outpoll.si_note, 1);
261
262 if (!tty_gone(tp))
263 ttydevsw_close(tp);
264
265 tp->t_flags &= ~TF_OPENCLOSE;
266 cv_broadcast(&tp->t_dcdwait);
267 tty_rel_free(tp);
268}
269
270/*
271 * Operations that are exposed through the character device in /dev.

Callers 2

ttydev_openFunction · 0.85
ttydev_closeFunction · 0.85

Calls 8

constty_clearFunction · 0.85
tty_drainFunction · 0.85
ttydisc_closeFunction · 0.85
ttyinq_freeFunction · 0.85
ttyoutq_freeFunction · 0.85
ttydevsw_closeFunction · 0.85
cv_broadcastFunction · 0.85
tty_rel_freeFunction · 0.85

Tested by

no test coverage detected