diff options
author | Arvydas Sidorenko <asido4@gmail.com> | 2012-06-16 12:54:51 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2012-06-18 01:28:01 +0200 |
commit | 363c03e79c334cc0f3d75c1a3b60edbca0214465 (patch) | |
tree | cebe9cd7d59ad4606fdcaa26046bc0a814bddc68 /widgets/raid.lua | |
parent | 8e35a983bf24f6f90df4630b2b55409f0ca1d213 (diff) | |
download | vicious-legacy-363c03e79c334cc0f3d75c1a3b60edbca0214465.tar.xz |
Fixed io.lines() bug
In Lua 5.2 io.lines() has to be used to iterate until EOF, otherwise
the fd will not be closed and eventually tons of naughty messages
will start to pop up saying that no more fd can be opened.
Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org>
Diffstat (limited to 'widgets/raid.lua')
-rw-r--r-- | widgets/raid.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/widgets/raid.lua b/widgets/raid.lua index e236d11..58a7359 100644 --- a/widgets/raid.lua +++ b/widgets/raid.lua @@ -4,7 +4,7 @@ ----------------------------------------------------- -- {{{ Grab environment -local io = { lines = io.lines } +local io = { open = io.open } local setmetatable = setmetatable local string = { len = string.len, @@ -33,7 +33,8 @@ local function worker(format, warg) } -- Linux manual page: md(4) - for line in io.lines("/proc/mdstat") do + local fd = io.open("/proc/mdstat") + for line in fd:lines() do if mddev[warg]["found"] then local updev = string.match(line, "%[[_U]+%]") @@ -50,6 +51,7 @@ local function worker(format, warg) end end end + fd:close() return {mddev[warg]["assigned"], mddev[warg]["active"]} end |