Skip to content

Commit

Permalink
Print out multiple snabb instance pids
Browse files Browse the repository at this point in the history
  • Loading branch information
dpino committed Aug 12, 2016
1 parent 048f2a8 commit bc8c2ab
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/program/top/top.lua
Expand Up @@ -39,14 +39,20 @@ function select_snabb_instance (pid)
if instance == pid then return pid end
end
print("No such Snabb instance: "..pid)
elseif #instances == 2 then
-- Two means one is us, so we pick the other.
local own_pid = tostring(S.getpid())
if instances[1] == own_pid then return instances[2]
else return instances[1] end
elseif #instances == 1 then print("No Snabb instance found.")
else print("Multple Snabb instances found. Select one.") end
os.exit(1)
else
local own_pid = tostring(S.getpid())
if #instances == 2 then
-- Two means one is us, so we pick the other.
return instances[1] == own_pid and instances[2] or instances[1]
else
print("Multiple Snabb instances found. Select one:")
for _, instance in ipairs(instances) do
if instance ~= own_pid then print(instance) end
end
end
end
main.exit(1)
end

function list_shm (pid, object)
Expand Down

0 comments on commit bc8c2ab

Please sign in to comment.