[PATCH] fix a resource leak in battery plugin

2 views
Skip to first unread message

Bart Trojanowski

unread,
Sep 19, 2008, 9:45:29 AM9/19/08
to Dave O'Neill, wmii...@googlegroups.com
---
plugins/battery.lua | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/plugins/battery.lua b/plugins/battery.lua
index 3538e4e..c5eec45 100644
--- a/plugins/battery.lua
+++ b/plugins/battery.lua
@@ -185,6 +185,7 @@ local function update_single_battery ( battery )
end

local batt = fbatt:read("*a")
+ fbatt:close()

local battpresent = batt:match('present:%s+(%w+)')
if battpresent ~= "yes" then
@@ -196,6 +197,7 @@ local function update_single_battery ( battery )

local fbattinfo = io.open(string.format(wmii.get_conf("battery.infofile"), battery["name"]),"r")
local battinfo = fbattinfo:read("*a")
+ fbattinfo:close()

local batt_percent = batt:match('remaining capacity:%s+(%d+)')
/ battinfo:match('last full capacity:%s+(%d+)') * 100
--
1.6.0.2.230.g944b04

Reply all
Reply to author
Forward
0 new messages