Thanks for the response - I'll take a look at the handbook.
Regarding ttywait, it was not called through the ttydrain ioctl.
ttywait was called through fdfree from exit1() when the login
process was exiting. I believe this is called with the vnode
Calling device close with the vnode lock held was a large bug. It was
one of the bugs fixed in 6.2 (devfs_vnops.c 126.96.36.199 2006/10/30 by
kib MFC 1.136 by kib). It was broken at a higher level by locking the
vnode in vn_close() starting before 6.0 (vfs_vnops.c 1.224 2005/03/13).