Naheel-Azawy/stpv

Ueberzug and fifo are not killed when lf is exited

NikitaIvanovV opened this issue · 4 comments

Thank you for making this helpful script! I use it with lf and I have one problem: when I exit lf, ueberzug is not killed and files in /tmp are still there. I tested a little bit and it looks like lf doesn't kill processes started with & when it is exited.

This workaround seems to work (added in ~/.config/lf/lfrc):

# stop stpvimg on exit
&{{
    while [ -e "/proc/$id" ]; do
        sleep 0.1
    done
    stpvimg --end $id
}}

Thank you for your contribution! It's great to know that my little script is actually useful.
For mess generated by stpvimg, that's certainly nasty and must be cleaned.

I haven't noticed this issue as I stopped using lf a while ago. Just checked and I do confirm that issue.
I think, maybe, when I used to use lf the behavior was different and it used to kill the process. That's probably why I trapped SIGEXIT in stpvimg if I remember correctly.

I remember that my earlier workaround was to have a wrapper around lf, something like what they call lfcd and call stpvimg --end $id once it's done.
Your workaround is kind of nicer as it's contained in lfrc. But I find looping and sleeping kind of too hacky.

But these are just workarounds and not solutions. It would've been nice if lf had a callback that runs before it quits.
Anyway, let's keep this open until a proper solution is found.

EDIT: Here're few old stuff you might find useful:

on-quit command has just been added to lf: gokcehan/lf@25476e7

So, this is now the correct configuration:

# file previews
set previewer stpv
set cleaner stpvimgclr
&stpvimg --listen $id
cmd on-quit $stpvimg --end $id

Oh nice. I remember the owner of lf rejected the idea of having something like on-quit few years ago.
But that's good now, thanks. I have added it to the readme.