MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / ttydev_leave

Function ttydev_leave

components/lwp/terminal/freebsd/tty.c:214–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214static void ttydev_leave(struct lwp_tty *tp)
215{
216 tty_assert_locked(tp);
217
218 if (tty_opened(tp) || tp->t_flags & TF_OPENCLOSE)
219 {
220 /* Device is still opened somewhere. */
221 tty_unlock(tp);
222 return;
223 }
224
225 tp->t_flags |= TF_OPENCLOSE;
226
227 /* Remove console TTY. */
228 constty_clear(tp);
229
230 /* Drain any output. */
231 if (!tty_gone(tp))
232 tty_drain(tp, 1);
233
234 ttydisc_close(tp);
235
236 /* Free i/o queues now since they might be large. */
237 ttyinq_free(&tp->t_inq);
238 tp->t_inlow = 0;
239 ttyoutq_free(&tp->t_outq);
240 tp->t_outlow = 0;
241
242#ifdef USING_BSD_KNOTE
243 knlist_clear(&tp->t_inpoll.si_note, 1);
244 knlist_clear(&tp->t_outpoll.si_note, 1);
245#endif
246
247 if (!tty_gone(tp))
248 ttydevsw_close(tp);
249
250 tp->t_flags &= ~TF_OPENCLOSE;
251 cv_broadcast(&tp->t_dcdwait);
252 tty_rel_free(tp);
253}
254
255/*
256 * Operations that are exposed through the character device in /dev.

Callers 2

ttydev_openFunction · 0.85
ttydev_closeFunction · 0.85

Calls 7

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

Tested by

no test coverage detected