You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Linux idle check: any /dev/pts entry or still-open login blocks idle-stop forever, defeating countActiveSessions' 'idle SSH sessions don't block' design #953
Found while auditing idle signals for #937. Verified by reading the code only; not observed on an instance.
isIdle checks sessions first, and does it carefully. countActiveSessions -> sysCountActiveSessions counts only sessions with input in the last 5 minutes (from the w idle column). Its doc gives the intent: "so idle SSH/RDP connections don't block idle detection."
Three checks later, on Linux, two presence-only checks undo that:
hasActiveTerminals -> sysHasActiveTerminals: any numeric entry in /dev/pts means "Not idle: Active terminals present". A PTY exists for every open SSH session, however long it has been idle, and also for every detached tmux/screen session, every docker run -t / docker exec -t, and every SSM Session Manager shell. None of them needs a human present.
hasRecentUserActivity -> sysHasRecentUserActivity: last -s -5min -w. util-linux documents --since as showing "the state of logins since the specified time", which includes sessions that are still logged in, whenever they started. So an open login seems to count as "recent activity" indefinitely. I have not checked this on AL2023.
(hasLoggedInUsers just calls countActiveSessions again, so it is redundant but harmless.)
Effect: on Linux, leaving an SSH session open, or leaving a detached tmux session behind (a common way to run a long job), blocks --idle-timeout forever. This is the "idle-stop can never fire" class of #919/#937, reached through presence checks rather than counters. The 5-minute idle-time logic in countActiveSessions has no effect while a PTY exists.
Windows is consistent: both checks are countActiveSessions() > 0.
Suggested fix: decide which is intended (rule 5). If it is the documented one, which says idle sessions must not block, then drop the presence checks, or base them on PTY idle time (for example the atime/mtime of /dev/pts/N, which is what w reads). Add a fixture test for "PTY open, idle 2 h, so idle".
A related point to check before fixing this. It is unverified and comes from reading the code.
sysCountActiveSessions reads the idle column from w -h -s as fields[3], which assumes the FROM column is printed. procps-ng's w(1) says FROM is toggled by -f, and that "the default as released is for the from field to not be printed", although distributions may build it the other way. Without FROM, fields[3] is the WHAT column (-bash), and isRecentActivity treats a format it does not know as "recent". Every session would then count as active whatever its idle time, which is the same "never idle" result as the presence checks above.
The PTY check currently hides this. If it is removed as suggested, the session parser needs a fixture for both column layouts. It would also be safer to locate the idle column structurally, by taking the field that parses as an idle time rather than a fixed index, or to read the PTY's atime directly.
Activity
scttfrdmn commentedon Oct 15, 2026
A related point to check before fixing this. It is unverified and comes from reading the code.
sysCountActiveSessionsreads the idle column fromw -h -sasfields[3], which assumes the FROM column is printed. procps-ng'sw(1)says FROM is toggled by-f, and that "the default as released is for the from field to not be printed", although distributions may build it the other way. Without FROM,fields[3]is the WHAT column (-bash), andisRecentActivitytreats a format it does not know as "recent". Every session would then count as active whatever its idle time, which is the same "never idle" result as the presence checks above.The PTY check currently hides this. If it is removed as suggested, the session parser needs a fixture for both column layouts. It would also be safer to locate the idle column structurally, by taking the field that parses as an idle time rather than a fixed index, or to read the PTY's atime directly.
Measure idle disk I/O as a per-tick delta over whole disks found by s…
Measure idle disk I/O as a per-tick delta over whole disks found by s…
Count a terminal as a session only while someone is typing in it (#953)
Move the #953 CHANGELOG entry into [Unreleased] after rebasing past v…
Remove isRecentActivity, which #923 moved to sys_linux.go and #953 le…
Read the real last-access time on Windows so the terminal idle tests …
Count a terminal as a session only while someone is typing in it (#953)
Remove isRecentActivity, which #923 moved to sys_linux.go and #953 le…
Read the real last-access time on Windows so the terminal idle tests …
Move the #953 CHANGELOG entry into [Unreleased] after rebasing past v…
Count a terminal as a session only while someone is typing in it (#953)
Remove isRecentActivity, which #923 moved to sys_linux.go and #953 le…
Read the real last-access time on Windows so the terminal idle tests …
Move the #953 CHANGELOG entry into [Unreleased] after rebasing past v…
Count a terminal as a session only while someone is typing in it (#953)…