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

Function ttydev_close

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

Source from the content-addressed store, hash-verified

371}
372
373static int ttydev_close(struct lwp_tty *tp, int fflag, int devtype __unused,
374 struct rt_thread *td __unused)
375{
376 rt_device_t dev = &tp->parent;
377
378 tty_lock(tp);
379
380 /*
381 * Don't actually close the device if it is being used as the
382 * console.
383 */
384 MPASS((tp->t_flags & (TF_OPENED_CONS | TF_OPENED_IN)) == 0 ||
385 (tp->t_flags & TF_OPENED_OUT) == 0);
386 if (dev == dev_console)
387 tp->t_flags &= ~TF_OPENED_CONS;
388 else
389 tp->t_flags &= ~(TF_OPENED_IN | TF_OPENED_OUT);
390
391 if (tp->t_flags & TF_OPENED)
392 {
393 tty_unlock(tp);
394 return 0;
395 }
396
397 /* If revoking, flush output now to avoid draining it later. */
398 if (fflag & FREVOKE)
399 tty_flush(tp, FWRITE);
400
401 tp->t_flags &= ~TF_EXCLUDE;
402
403 /* Properly wake up threads that are stuck - revoke(). */
404 tp->t_revokecnt++;
405 tty_wakeup(tp, FREAD | FWRITE);
406 cv_broadcast(&tp->t_bgwait);
407 cv_broadcast(&tp->t_dcdwait);
408
409 ttydev_leave(tp);
410
411 return 0;
412}
413
414int tty_wait_background(struct lwp_tty *tp, struct rt_thread *td, int sig)
415{

Callers

nothing calls this directly

Calls 3

tty_flushFunction · 0.85
tty_wakeupFunction · 0.85
ttydev_leaveFunction · 0.85

Tested by

no test coverage detected