equal
deleted
inserted
replaced
|
1 #!/usr/bin/ruby |
|
2 |
|
3 BEGIN { |
|
4 require 'pathname' |
|
5 basedir = Pathname.new( __FILE__ ).dirname.parent |
|
6 |
|
7 $LOAD_PATH.unshift basedir + "ext" unless |
|
8 $LOAD_PATH.include? basedir + "ext" |
|
9 } |
|
10 |
|
11 |
|
12 require 'bsdjail' |
|
13 |
|
14 jid = Integer( ARGV.shift ) |
|
15 args = ARGV |
|
16 |
|
17 $deferr.puts "In process #{Process.pid}, about to jail_attach() with a block" |
|
18 |
|
19 childpid = BSD::Jail.attach( jid ) do |
|
20 Dir.chdir( "/" ) |
|
21 $deferr.puts "Child #{Process.pid} exec()ing:", " " + args.join(" ") |
|
22 exec( *args ) |
|
23 end |
|
24 |
|
25 $deferr.puts "Parent: waiting on imprisoned child #{childpid}" |
|
26 Process.waitpid( childpid ) |
|
27 |
|
28 $deferr.puts "Child exited with exit code: %d" % [ $?.exitstatus ] |
|
29 |