Controls tty locking functions.
Standard C Library (libc.a)
int ttylock (DeviceName) char *DeviceName;
int ttywait (DeviceName) char *DeviceName;
int ttyunlock (DeviceName) char *DeviceName;
int ttylocked (DeviceName) char *DeviceName;
The ttylock subroutine creates the LCK..DeviceName file in the /etc/locks directory and writes the process ID of the calling process in that file. If LCK..DeviceName exists and the process whose ID is contained in this file is active, the ttylock subroutine returns an error.
There are programs like uucp and connect that create tty locks in the /etc/locks directory. The convention followed by these programs is to call the ttylock subroutine with an argument of DeviceName for locking the /dev/DeviceName file. This convention must be followed by all callers of the ttylock subroutine to make the locking mechanism work.
The ttywait subroutine blocks the calling process until the lock file associated with DeviceName, the /etc/locks/LCK..DeviceName file, is removed.
The ttyunlock subroutine removes the lock file, /etc/locks/LCK..DeviceName, if it is held by the current process.
The ttylocked subroutine checks to see if the lock file, /etc/locks/LCK..DeviceName, exists and the process that created the lock file is still active. If the process is no longer active, the lock file is removed.
|DeviceName||Specifies the name of the device.|
Upon successful completion, the ttylock subroutine returns a value of 0. Otherwise, a value of -1 is returned.
The ttylocked subroutine returns a value of 0 if no process has a lock on device. Otherwise, a value of -1 is returned.
rc = ttylock("tty0");
if (ttylock("tty0")) ttywait("tty0"); rc = ttylock("tty0");
rc = ttylocked("tty0");
These subroutines are part of Base Operating System (BOS) Runtime.
The /etc/locks directory.
The Input and Output Handling Programmer's Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.