mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-23 13:15:14 +09:00
Solves issues dealing with pager for CLI
(cherry picked from commit 58af3b5ec9)
This commit is contained in:
1 parent
08bfc40b72
commit
ba32d6ddb6
2 files changed
+18
-1
No files matched your search
+13
-1
@@ -541,7 +541,10 @@ EOT
|
||||
def stop_pager(lpid)
|
||||
$stdout.close
|
||||
|
||||
Process.wait(lpid)
|
||||
begin
|
||||
Process.wait(lpid)
|
||||
rescue Errno::ECHILD
|
||||
end
|
||||
end
|
||||
|
||||
def print_page(pool, options)
|
||||
@@ -599,6 +602,9 @@ EOT
|
||||
|
||||
if elements < size
|
||||
return 0
|
||||
elsif !pool.is_paginated?
|
||||
stop_pager(ppid)
|
||||
return 0
|
||||
end
|
||||
|
||||
# ------- Rest of the pages in the pool, piped to pager --------
|
||||
@@ -613,6 +619,12 @@ EOT
|
||||
|
||||
current += size
|
||||
|
||||
begin
|
||||
Process.waitpid(ppid, Process::WNOHANG)
|
||||
rescue Errno::ECHILD
|
||||
break
|
||||
end
|
||||
|
||||
elements, hash = print_page(pool, options)
|
||||
|
||||
table.show(hash, options)
|
||||
|
||||
@@ -247,5 +247,10 @@ module OpenNebula
|
||||
|
||||
return rc
|
||||
end
|
||||
|
||||
# Return true if pool is paginated
|
||||
def is_paginated?
|
||||
PAGINATED_POOLS.include?(@pool_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user