Public bug reported:

procps-ng watch 4.0.4

Ubuntu 24.04.5 LTS

procps:
  Installed: 2:4.0.4-4ubuntu3.3
  Candidate: 2:4.0.4-4ubuntu3.3
  Version table:
 *** 2:4.0.4-4ubuntu3.3 500
        500 http://us.archive.ubuntu.com/ubuntu noble-updates/main amd64 
Packages
        100 /var/lib/dpkg/status
     2:4.0.4-4ubuntu3 500
        500 http://us.archive.ubuntu.com/ubuntu noble/main amd64 Packages

When a command run under watch produces more output than fits on the
terminal screen, watch closes its command-output pipe after reading the
screen-sized portion. Subsequent writes encounter a broken pipe
(SIGPIPE).

This can change the outcome of the monitored script rather than merely
truncating its displayed output.

Steps to reproduce

Run a Bash script under watch -n 1.
Have the script produce enough output to fill the terminal screen.
Execute a Bash built-in printf "\n" after the output has filled the screen.
Observe that the script terminates before executing subsequent commands.

In my testing, external cat commands encountered exit status 141, while
the built-in printf was associated with premature termination of the
script. Removing the printf allowed the script to complete. Redirecting
the script's output to a file also allowed it to complete with exit
status 0.

Impact

The script failed to execute its temporary-file cleanup, resulting in
temporary files accumulating over multiple days and eventually filling a
disk partition.

Expected behavior

Exceeding the display limit should truncate or discard excess displayed
output without causing the monitored script to terminate prematurely.

Implementation detail

Per ChatGPT analysis, in the procps-ng 4.0.4 source, watch closes its
command-output stream after reading the terminal-sized display region.
Please consider draining excess output before closing the pipe, or
another approach that prevents the display limit from changing the
command's execution outcome.

A cleanup trap provides a workaround, but does not address the
underlying behavior.

** Affects: procps (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2171569

Title:
  watch 4.0.4 closes command output pipe at screen limit, causing
  monitored script to terminate

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/procps/+bug/2171569/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to