diff options
-rw-r--r-- | applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua b/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua index bb56bc6e6..a8c577929 100644 --- a/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua +++ b/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua @@ -28,16 +28,17 @@ local function exec(cmd, args, writer) while true do local buffer = fdi:read(2048) - local wpid, stat, code = nixio.waitpid(pid, "nohang") - if writer and buffer and #buffer > 0 then - writer(buffer) + if not buffer or #buffer == 0 then + break end - if wpid and stat == "exited" then - break + if writer then + writer(buffer) end end + + nixio.waitpid(pid) elseif pid == 0 then nixio.dup(fdo, nixio.stdout) fdi:close() |