VHANGUP(2)

NAME
vhangup - virtually ``hangup'' the current control terminal

SYNOPSIS
vhangup()

DESCRIPTION
Vhangup is used by the initialization process init(8) (among others) to arrange that users are given “clean”' terminals at login, by revoking access of the previous users' processes to the terminal. To effect this, vhangup searches the system tables for references to the control terminal of the invoking process, revoking access permissions on each instance of the terminal which it finds. Further attempts to access the terminal by the affected processes will yield i/o errors (EBADF). Finally, a hangup signal (SIGHUP) is sent to the process group of the control terminal.

The use of this call is restricted to the superuser.

RETURN VALUE
A 0 return value indicates success. A -1 return value indicates an error, and an error code is stored in errno.

ERRORS

[EPERM]
    The caller is not the superuser.

SEE ALSO
init (8)

BUGS
Access to the control terminal via /dev/tty is still possible.

If the device can be opened through two different inodes (distinct, non-hardlinked filenames created with separate mknod(2) calls), processes that have the alternate inodes open do not receive the hangup signal.

This call should be replaced by an automatic mechanism which takes place on process exit.