--- a/examples/jexec.rb Sat Feb 28 06:52:48 2009 +0000
+++ b/examples/jexec.rb Tue Mar 03 22:23:45 2009 +0000
@@ -1,29 +1,18 @@
-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+#
+# An example 'jexec' in ruby.
+#
BEGIN {
require 'pathname'
basedir = Pathname.new( __FILE__ ).dirname.parent
-
+
$LOAD_PATH.unshift basedir + "ext" unless
$LOAD_PATH.include? basedir + "ext"
}
-
-require 'bsdjail'
-
-jid = Integer( ARGV.shift )
-args = ARGV
-
-$deferr.puts "In process #{Process.pid}, about to jail_attach() with a block"
+require 'jail'
-childpid = BSD::Jail.attach( jid ) do
- Dir.chdir( "/" )
- $deferr.puts "Child #{Process.pid} exec()ing:", " " + args.join(" ")
- exec( *args )
-end
+BSD::Jail.attach( ARGV.shift.to_i )
+exec( *ARGV )
-$deferr.puts "Parent: waiting on imprisoned child #{childpid}"
-Process.waitpid( childpid )
-
-$deferr.puts "Child exited with exit code: %d" % [ $?.exitstatus ]
-