[info] How to fix a zombie mpv process

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
1,085
Reaction score
921
Credits
8,337
In short: you use SMPlayer with mpv bc SMP provides options that mpv doesn't have. But sometimes when you close SMP, mpv doesn't shutdown and remains hanging as a zombie process. If you're NOT using the option of SMP for a single process of SMP, that's somewhat fine and you won't notice for some time - well, at least until you open system monitor and see dozens of mpv processes that do nothing.

This started happening since SMP 23.12 and either the dev can't find the cause or has no intention of fixing it bc this going on for 2 years already. However, I found a 100% working way to close mpv AFTER SMP has been closed.

1. Go to ~/.config/mpv and create a dir named "scripts".
2. Create an empty file named "autoquit.lua", put the following code in it and save it. No need to reboot, it starts working almost instantly.

Code:
mp.register_event("end-file", function()
    mp.command("quit")
end)

mp.register_event("window-close", function()
    mp.command("quit")
end)

local timer = mp.add_periodic_timer(0.5, function()
    local idle = mp.get_property_native("idle-active")
    if idle then
        mp.command("quit")
    end
end)
 


Follow Linux.org

Members online


Top