URL:
  <https://savannah.gnu.org/bugs/?67855>

                 Summary: Screen does not exit on tty disappearence
                   Group: GNU Screen
               Submitter: None
               Submitted: Пн 22 дек 2025 22:54:59
                Category: Program Logic
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Unlocked
                 Release: 5.0.1
           Fixed Release: None
         Planned Release: None
           Work Required: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Пн 22 дек 2025 22:54:59   By: Anonymous
When screen 5.0.0 or 5.0.1 is used to connect to serial port (/dev/ttyUSB0),
screen is not terminated after the USB serial is disconnected from the USB
port.

Screen manages to disconnect from the user terminal (where it has been
started), but keep hanging in the process list.
It also keeps the /dev/ttyUSB0 device open, so replugging the serial converter
results in ttyUSB1, not 0.


I've tried to bisect the issue, and the first bad commit is

commit c2d797a3792a6e9ee4276600cc00f22e121bc8e2
Author: Amadeusz Sławiński <[email protected]>
Date:   Mon Feb 3 23:38:48 2020 +0100

    Fix 100% cpu use on one core with poll
    
    If there is no event timeout set just wait for 1 second instead of
    setting poll timeout to 0.




However reverting it on the 5.0.1 does nothing.
Reverting works if I checkout commit

commit 6501c377b2059310bbfdaf7b217d31717abf648b
Author: Alexander Naumov <[email protected]>
Date:   Sat Jul 27 12:00:26 2024 +0200

    hardstatus: move 'the count of screen windows' from 'C' to 'O'



but after the next commit

commit 500144ee453b2cc2d52cb21ee1b002c17506f1fa
Author: Alexander Naumov <[email protected]>
Date:   Sat Jul 27 13:58:42 2024 +0200

    Regression bugfix: harstatus string fails to display date & time


reverting c2d797a3792a6e9ee4276600cc00f22e121bc8e2 doesn't work.

It seems there's a race condition between SIGHUP and termination routine.



If I attach strace before unplugging the USB converter, I get:

poll([{fd=3</dev/pts/16<char 136:16>>, events=POLLIN}, {fd=0</dev/null<char
1:3>>, events=0}, {fd=5</dev/ttyUSB0<char 188:0>>, events=POLLIN},
{fd=0</dev/null<char 1:3>>, events=0},
{fd=4<UNIX-STREAM:[8850853,"/root/.screen/2148502.pts-16.fedora"]>,
events=POLLIN}], 5, 483724) = 1 ([{fd=5, revents=POLLIN|POLLERR|POLLHUP}])

-- /dev/ttyUSB0 DISCONNECTED HERE --

--- SIGHUP {si_signo=SIGHUP, si_code=SI_KERNEL} ---
--- SIGCONT {si_signo=SIGCONT, si_code=SI_KERNEL} ---
close(3</dev/pts/16<char 136:16>>)      = 0
rt_sigaction(SIGHUP, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER,
sa_restorer=0x7efc907fa290}, {sa_handler=0x403b38, sa_mask=[],
sa_flags=SA_RESTORER, sa_restorer=0x7efc907fa290}, 8) = 0
geteuid()                               = 0
chmod("/root/.screen/2148502.pts-16.fedora", 0600) = 0
utimensat(AT_FDCWD</home/valdikss/screen/src>,
"/root/.screen/2148502.pts-16.fedora", NULL, 0) = 0
kill(2148501, SIGHUP)                   = 0
rt_sigaction(SIGHUP, {sa_handler=0x403b38, sa_mask=[], sa_flags=SA_RESTORER,
sa_restorer=0x7efc907fa290}, {sa_handler=SIG_IGN, sa_mask=[],
sa_flags=SA_RESTORER, sa_restorer=0x7efc907fa290}, 8) = 0
rt_sigreturn({mask=[]})                 = 1
accept(4<UNIX-STREAM:[8850853,"/root/.screen/2148502.pts-16.fedora"]>    <--
hangs indefinitely


And if I `sudo screen -x`, it prints `[screen is terminating]` and properly
exits the process.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?67855>

_______________________________________________
Сообщение отправлено по Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to