FIX nil makes interface crash when pid not found

This commit is contained in:
Nathan Dwarshuis 2022-07-23 22:10:45 -04:00
parent 9cabca8207
commit 53f046bd9b
1 changed files with 2 additions and 1 deletions

View File

@ -206,8 +206,9 @@ return function(update_freq, config, main_state, common, width, point)
local update = function() local update = function()
for r = 1, num_rows do for r = 1, num_rows do
local pid = i_o.conky(table_conky[r].pid, '(%d+)') -- may have leading spaces local pid = i_o.conky(table_conky[r].pid, '(%d+)') -- may have leading spaces
local name = i_o.read_file('/proc/'..pid..'/comm', '(%C+)') or 'N/A'
if pid ~= '' then if pid ~= '' then
text_table.set(tbl, 1, r, i_o.read_file('/proc/'..pid..'/comm', '(%C+)')) text_table.set(tbl, 1, r, name)
text_table.set(tbl, 2, r, pid) text_table.set(tbl, 2, r, pid)
text_table.set(tbl, 3, r, i_o.conky(table_conky[r].cpu)) text_table.set(tbl, 3, r, i_o.conky(table_conky[r].cpu))
end end