aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xaataaj.lua22
1 files changed, 11 insertions, 11 deletions
diff --git a/aataaj.lua b/aataaj.lua
index d5b081e..b139faa 100755
--- a/aataaj.lua
+++ b/aataaj.lua
@@ -94,12 +94,13 @@ APT.readCmd = function(cmd)
94 table.insert(result, l) 94 table.insert(result, l)
95 end 95 end
96 end 96 end
97 -- While this does return the same things as os.execute(), it's just as useless.
98 output:close()
97 return result 99 return result
98end 100end
99 101
100
101APT.exe = function(c) 102APT.exe = function(c)
102 local exe = {status = 0, result = '', lines = {}, log = true, cmd = c .. ' ', command = c} 103 local exe = {status = 0, lines = {}, log = true, cmd = c .. ' ', command = c}
103 104
104 function exe:log() 105 function exe:log()
105 self.log = true 106 self.log = true
@@ -159,15 +160,14 @@ APT.exe = function(c)
159 I'm getting 7168 or 0. No idea what the fuck that is. 160 I'm getting 7168 or 0. No idea what the fuck that is.
160 local ok, rslt, status = os.execute(s) 161 local ok, rslt, status = os.execute(s)
161 ]] 162 ]]
162 local f = APT.readCmd(self.cmd .. '; echo "$?"', 'r') 163 self.lines = APT.readCmd(self.cmd .. '; echo "$?"', 'r')
163 -- The last line will be the command's returned status, collect everything else in result. 164 -- The last line will be the command's returned status, collect everything else in result.
164 self.status = tonumber(f[#f]) 165 self.status = tonumber(self.lines[#self.lines])
165 f[#f] = nil 166 self.lines[#self.lines] = nil
166 self.result = '\n' 167-- self.result = '\n'
167 self.lines = f 168-- for i,l in ipairs(self.lines) do
168 for i,l in ipairs(f) do 169-- self.result = self.result .. l .. "\n"
169 self.result = self.result .. l .. "\n" 170-- end
170 end
171 if (137 == self.status) or (124 == self.status) then 171 if (137 == self.status) or (124 == self.status) then
172 print("timeout killed " .. self.status .. ' ' .. self.command) 172 print("timeout killed " .. self.status .. ' ' .. self.command)
173 print('ERROR ' .. "timeout killed " .. self.status .. ' ' .. self.command) 173 print('ERROR ' .. "timeout killed " .. self.status .. ' ' .. self.command)
@@ -196,7 +196,7 @@ end
196APT.killEmAll = function(all) 196APT.killEmAll = function(all)
197 for i,l in ipairs(all) do 197 for i,l in ipairs(all) do
198 local c = 0 198 local c = 0
199 while 0 ~= tonumber(APT.exe("pgrep -u $USER -xc " .. l):Do().result) do 199 while 0 ~= tonumber(APT.exe("pgrep -u $USER -xc " .. l):Do().lines[1]) do
200 local s = 'TERM' 200 local s = 'TERM'
201 if c > 0 then s = 'KILL'; APT.exe("sleep " .. c):Do() end 201 if c > 0 then s = 'KILL'; APT.exe("sleep " .. c):Do() end
202 print( "pkill -" .. s .. " -u $USER -x " .. l) 202 print( "pkill -" .. s .. " -u $USER -x " .. l)