It took me a while to narrow this down and I haven't figured it out completely yet, but sometimes the last cat in the subshell with the loop is not killed and does not exit after the vimcat process is complete.
#!/usr/bin/env bash
echo "'cat' processes before:"
pgrep -af vimcat_out.fifo
echo "-----"
./vimcat << EOF
Just some sample text
Line 2
Line 3
EOF
echo "'cat' processes after:"
pgrep -af vimcat_out.fifo
echo "-----"
Running the script produces:
'cat' processes before:
-----
Just some sample text
cat_pid: 12135
Line 2
Line 3
cat_pid: 12169
Killing v12136 p12140 t12134
'cat' processes after:
12172 cat /tmp/vimcat_12125/vimcat_out.fifo
-----
and each subsequent run adds another leftover process. Changing the input into vimcat to a file or anything else (even a single character) has the same issue. I made it multiple lines to show that only the last $cat_pid stays running.
I guess a workaround (or even a solution?) would be to keep $cat_pid around and kill it in quit() along with all the other processes, but I'm wondering if there's a cleaner way. I'd also be curious to know why this is happening and if it is happening for anyone else.
This occurs on several machines, all with the following information:
OS: Arch Linux
Shell: zsh 5.5.1 (reproducible with bash 4.4.19)
Vim: 8.1
Vimcat: 2.06-351-gfdc74aa (current master)
It took me a while to narrow this down and I haven't figured it out completely yet, but sometimes the last
cat
in the subshell with the loop is not killed and does not exit after the vimcat process is complete.I'm referring to the following line: https://github.com/rkitover/vimpager/blob/fdc74aab4a10a9a0ad994db15fe80f25b3df4740/vimcat#L305
It appears the subshell is properly killed at the end (
$tail_pid
), but not the absolute last cat in the loop.I made the following changes to the vimcat script in order to figure out which exact invocation of cat was staying behind:
And use this script to test:
Running the script produces:
and each subsequent run adds another leftover process. Changing the input into vimcat to a file or anything else (even a single character) has the same issue. I made it multiple lines to show that only the last
$cat_pid
stays running.I guess a workaround (or even a solution?) would be to keep
$cat_pid
around and kill it inquit()
along with all the other processes, but I'm wondering if there's a cleaner way. I'd also be curious to know why this is happening and if it is happening for anyone else.This occurs on several machines, all with the following information: OS: Arch Linux Shell: zsh 5.5.1 (reproducible with bash 4.4.19) Vim: 8.1 Vimcat: 2.06-351-gfdc74aa (current master)