lib/arborist/monitor.rb in arborist-0.0.1.pre20160128152542 vs lib/arborist/monitor.rb in arborist-0.0.1.pre20160606141735

- old
+ new

@@ -33,11 +33,11 @@ ## # The default number of seconds to defer startup to splay common intervals DEFAULT_SPLAY = 0 - Arborist.add_dsl_constructor( :Monitor ) do |description, &block| + Arborist.add_dsl_constructor( self ) do |description, &block| Arborist::Monitor.new( description, &block ) end # The module that contains the default logic for invoking an external program @@ -248,9 +248,18 @@ context.exec_input( nodes, parent_writer ) parent_writer.close return context.handle_results( pid, parent_reader, parent_err_reader ) + rescue SystemCallError => err + self.log.error "%p while running external monitor command `%s`: %s" % [ + err.class, + Shellwords.join( command ), + err.message + ] + self.log.debug " %s" % [ err.backtrace.join("\n ") ] + return {} + ensure if pid begin Process.kill( 0, pid ) # waitpid if it's still alive Process.waitpid( pid )