Clearing a hung TTY port
In this example of clearing a hung port, assume that the hung tty port is
tty0
.
You must have root authority to be able to complete this procedure.
- Determine whether the tty is currently handling any processes by typing the
following:
ps -lt tty0
This should return results similar to the following:
The Process ID (PID) here is 22566. To kill this process, type the following:F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 240001 S 202 22566 3608 0 60 20 781a 444 70201e44 tty0 0:00 ksh
kill 22566
Ensure that the process was successfully cleared by typing the commandps -lt tty0
. If the process still exists, add the-9
flag to the kill command as shown in the example below.Note: Do not use the -9 option to kill an slattach process. Killing an slattach process with the-9
flag might cause a slip lock to remain in the /etc/locks file. Delete this lock file to clean up after slattach.kill -9 22566
- Determine if any process is attempting to use the tty by typing the following:
ps -ef | grep tty0
Note: If the ps -ef | grep tty command returns something similar to the following:
where the "-" is displayed between the date (root 19050 1 0 Mar 06 - 0:00 /usr/sbin/getty /dev/tty
Mar 06
) and the time (0:00
), this tty does not have the correct cable. This status indicates that the system login process (getty) is attempting to open this tty, and the open process is hanging because the RS-232 signal Data Carrier Detect (DCD) is not asserted. You can fix this by using the correct null modem adapter in the cabling. When getty can open the tty port, the "-" is replaced by the tty number. For more information on cables, see Attaching the modem with appropriate cables.Note: The following command can be used to disable the login process ontty0
.pdisable tty0
If the process has been successfully cleared but the tty is still unresponsive, continue to the next step.
- Type the following command:
This will clear any process that can be found running on the port and display the PID. If the tty is still unusable, continue to the next step.fuser -k /dev/tty0
- Use the strreset command to flush outgoing data from the port that is
hung due to data that cannot be delivered because the connection to the remote end has been lost. Note: If the strreset command fixes the hung port, the port has a cable or configuration problem because the loss of the connection to the remote end should have caused buffered data to be flushed automatically.You need to first determine the major and minor device numbers for the tty by typing the following:
Your results should look similar to the following:ls -al /dev/tty0
This indicates thatcrw-rw-rw- 1 root system 18, 0 Nov 7 06:19 /dev/tty0
tty0
has a major device number of 18 and a minor device number of 0. Specify these numbers when using the strreset command as follows:
If the tty is still unusable, continue to the next step./usr/sbin/strreset -M 18 -m 0
- Detach and reattach the cable from the hung tty port. AIX uses the Data Carrier Detect (DCD) signal to
determine the presence of a device attached to the port. By dropping DCD, detaching and reattaching the cable will in many cases clear hung processes.To determine the location of the port on which the tty is configured, type the following command:
The results should look similar to the following:lsdev -Cl tty0
The third column in the above output indicates the location code of the tty. In this example,tty0 Available 00-00-S1-00 Asynchronous Terminal
S1
indicates the serial port is configured for native serial port 1. For more information on interpreting location codes, see ../devicemanagement/devloccodes.html in Operating system and device management.If the tty is still unusable, continue to the next step.
- Flush the port using stty-cxma. Type the following:
/usr/lbin/tty/stty-cxma flush tty0
This command is intended for the ttys configured on ports of the 8-port and 128-adapters. In some cases, however, it can be used successfully to flush other tty ports.
If the tty is still unusable, continue to the next step.
- On the keyboard of the hung terminal, hold down the
Ctrl
key and pressQ
. This will resume any suspended output by sending an Xon character.If the tty is still unusable, continue to the next step.
- A program will sometimes open a tty port, modify some attributes, and close the port
without resetting the attributes to their original states. To correct this, bring the tty down to a
DEFINED state and then make it available by typing the following:
This command leaves the information concerning the tty in the database but makes the tty unavailable on the system.rmdev -l tty0
The following command reactivates the tty:If the tty is still unusable, consider moving the device to another port and configuring a tty at that location until the system can be rebooted. If rebooting does not clear the port, you most likely have a hardware problem. Check the error report for port hardware problems by entering the following:mkdev -l tty0
errpt -a | pg
Some of the preceding commands will not work, and they will give a method error indicating
that the device is busy. This is because of the process running on the tty. If none of the steps
detailed above free the hung tty, as a last resort, reboot the AIX system and flush the kernel so that the
process will go away.