diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 09da351e47..86db43af18 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -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) diff --git a/src/oca/ruby/opennebula/pool.rb b/src/oca/ruby/opennebula/pool.rb index 99e6a83e85..9af0c5b857 100644 --- a/src/oca/ruby/opennebula/pool.rb +++ b/src/oca/ruby/opennebula/pool.rb @@ -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