FS#18254 - lesspipe is stopped when SIGCHLD has a handler

Attached to Project: Community Packages
Opened by Ted Pavlic (tpavlic) - Tuesday, 09 February 2010, 16:48 GMT
Last edited by Andrea Scarpino (BaSh) - Tuesday, 09 February 2010, 17:35 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: When there is a bash handler for SIGCHLD, lesspipe is stopped when the process emptying into the pipe finishes. This problem might be able to be fixed by making lesspipe create a named pipe (i.e., with "mkfifo") rather than simply dumping into a temporary file.

Additional info:
* lesspipe 1.70-4
* Have also e-mailed the author

Steps to reproduce:

1. Put this simple script into .bashrc (e.g., for telling bash the proper window width after a resize so that commands always wrap correctly):

#####################################
sizetw 26 100
function updwin() {
NUMLINES=$(tput lines)
NUMCOLS=$(tput cols)
sizetw ${NUMLINES} ${NUMCOLS}
return 0
}
trap updwin SIGWINCH
trap updwin SIGCHLD
#####################################

2. Then, after starting a new bash shell that executes that script, try:

# cat /etc/services | less

(with lesspipe installed and LESSOPEN set properly).


3. less should pause on the first page. After a few seconds, hit the "down" cursor to move down in the file. bash should then report that the process was "Stopped" (which can be confirmed with the "jobs" command). The user then has to issue a "fg" to get the process back and quit the less.


I speculate that lesspipe.sh is redirecting all output to a temporary file. That allows piped processes to end early, which triggers the SIGCHLD. If lesspipe used a named pipe (i.e., a file made with "mkfifo") instead, it would not only save space on the disk, but the source of less's piped input should stay open as it blocks waiting for the fifo to hit its end of file.

This task depends upon

Closed by  Andrea Scarpino (BaSh)
Tuesday, 09 February 2010, 17:35 GMT
Reason for closing:  Duplicate
Additional comments about closing:   FS#18255 
Comment by Ted Pavlic (tpavlic) - Tuesday, 09 February 2010, 17:09 GMT
This problem does not seem to be linked to lesspipe. In fact, it occurs with less regardless of whether lesspipe is installed. The problem is with less, not lesspipe.

(I assumed that lesspipe was the problem because a Darwin machine I have access to that is not running lesspipe does not have the problem)

Loading...