Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-105319

less needs to reset the SIGHUP handler to default otherwise it may survive terminal abrupt closing

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a Bug
    • Icon: Undefined Undefined
    • None
    • rhel-8.10, rhel-9.6
    • less
    • None
    • No
    • Low
    • 1
    • rhel-base-utils-core
    • 1
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • Red Hat Enterprise Linux
    • BaseUtilsC Sprint CY25_00
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      If the user execute less then hit the "F" (follow file), the file being monitored is polled regularly to get updates.
      If the user first added a trap to ignore SIGHUP before executing less, then closed the terminal abruptly, this leads to still having less monitor the file "in the background", despite the user not having a session anymore, instead of quitting.

      Reproducer

      1. Open a terminal
      2. Set a trap to ignore SIGHUP
        $ trap "" HUP
      3. Execute less on a file
        $ less some_file
      4. Hit "F" to follow
      5. Close abruptly the terminal

      Expected result

      less exits on its own.

      Actual result

      less remains in the background:

      # ps -eaf | grep less | grep -v grep
      root        6427    6372  0 13:05 ?        00:00:00 less anaconda-ks.cfg
      
      # strace -fttTvyy -s 128 -p 6427
      strace: Process 6427 attached
      13:06:00.084445 restart_syscall(<... resuming interrupted nanosleep ...>) = 0 <0.178072>
      13:06:00.262753 read(4</root/anaconda-ks.cfg>, "", 6614) = 0 <0.000090>
      13:06:00.263119 nanosleep({tv_sec=1, tv_nsec=0}, 0x7ffddb156c20) = 0 <1.000318>
      13:06:01.263715 read(4</root/anaconda-ks.cfg>, "", 6614) = 0 <0.000070>
      13:06:01.264066 nanosleep({tv_sec=1, tv_nsec=0}, 0x7ffddb156c20) = 0 <1.000232>
      ...
      

      The reason for behavior is SIGHUP is ignored, IMHO less code should restore the default handler for SIGHUP.

              mhlavink Michal Hlavinka
              rhn-support-rmetrich Renaud Métrich
              Michal Hlavinka Michal Hlavinka
              RHEL SST CS base utils QE Bot RHEL SST CS base utils QE Bot
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: