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

Function ttydev_close

freebsd/kern/tty.c:373–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373static int
374ttydev_close(struct cdev *dev, int fflag, int devtype __unused,
375 struct thread *td __unused)
376{
377 struct tty *tp = dev->si_drv1;
378
379 tty_lock(tp);
380
381 /*
382 * Don't actually close the device if it is being used as the
383 * console.
384 */
385 MPASS((tp->t_flags & (TF_OPENED_CONS | TF_OPENED_IN)) == 0 ||
386 (tp->t_flags & TF_OPENED_OUT) == 0);
387 if (dev == dev_console)
388 tp->t_flags &= ~TF_OPENED_CONS;
389 else
390 tp->t_flags &= ~(TF_OPENED_IN|TF_OPENED_OUT);
391
392 if (tp->t_flags & TF_OPENED) {
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
414static __inline int
415tty_is_ctty(struct tty *tp, struct proc *p)

Callers

nothing calls this directly

Calls 4

tty_flushFunction · 0.85
tty_wakeupFunction · 0.85
cv_broadcastFunction · 0.85
ttydev_leaveFunction · 0.85

Tested by

no test coverage detected