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.

  1. Determine whether the tty is currently handling any processes by typing the following:
    ps -lt tty0
    This should return results similar to 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
    The Process ID (PID) here is 22566. To kill this process, type the following:
    kill 22566
    Ensure that the process was successfully cleared by typing the command ps -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
  2. 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:
    root 19050      1    0    Mar 06       -  0:00 /usr/sbin/getty /dev/tty
    where the "-" is displayed between the date (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 on tty0.
    pdisable tty0

    If the process has been successfully cleared but the tty is still unresponsive, continue to the next step.

  3. Type the following command:
    fuser -k /dev/tty0
    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.
  4. 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:
    ls -al /dev/tty0
    Your results should look similar to the following:
    crw-rw-rw-    1 root     system    18,   0 Nov  7  06:19 /dev/tty0
    This indicates that 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:
    /usr/sbin/strreset -M 18 -m 0
    If the tty is still unusable, continue to the next step.
  5. 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:
    lsdev -Cl tty0
    The results should look similar to the following:
    tty0    Available   00-00-S1-00  Asynchronous Terminal
    The third column in the above output indicates the location code of the tty. In this example, 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.

  6. 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.

  7. On the keyboard of the hung terminal, hold down the Ctrl key and press Q. This will resume any suspended output by sending an Xon character.

    If the tty is still unusable, continue to the next step.

  8. 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:
    rmdev -l tty0
    This command leaves the information concerning the tty in the database but makes the tty unavailable on the system.
    The following command reactivates the tty:
    mkdev -l tty0
    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:
    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.