docs/example.rb
author Mahlon E. Smith <mahlon@martini.nu>
Thu, 25 Dec 2008 08:35:46 +0000
branchmahlon-misc
changeset 11 e908d309e7ec
parent 0 92d00ff32c56
permissions -rw-r--r--
* It compiles! * Removed additional leftover link parser stuff. * Removed unused memory allocate/free stuff until I discuss with my cohort. It may be back... it may be left over from linkparser too. ;) * list() works, but cores. Not sure why yet. Really, list() should be renamed to something sensible, and return instantiated BSD::Jail objects to attach() to or get additional info on. * Ruby C bindings are way, way fun. Reminds me how little C I can remember with one project a year :)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
     1
#!/usr/bin/ruby
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
     2
# 
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
     3
# Example jail_attach usage
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
     4
# 
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
     5
# == Synopsis
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
     6
# 
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
     7
#   
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
     8
# 
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
     9
# == Authors
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    10
# 
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    11
# * Michael Granger <ged@FaerieMUD.org>
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    12
# 
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    13
# == Copyright
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    14
#
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    15
# Copyright (c) 2006 The FaerieMUD Consortium. Some rights reserved.
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    16
# 
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    17
# This work is licensed under the Creative Commons Attribution License. To view
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    18
# a copy of this license, visit http://creativecommons.org/licenses/by/1.0/ or
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    19
# send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    20
# 94305, USA.
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    21
# 
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    22
# == Version
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    23
#
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    24
#  $Id$
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    25
# 
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    26
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    27
require 'bsdjail'
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    28
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    29
# With a block, does a fork() then a jail_attach() from the child
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    30
pid = BSDJail.attach( jid ) do
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    31
	puts "I'm a child process in jail!"
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    32
	
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    33
	
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    34
end
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    35
92d00ff32c56 Initial checkin
Michael Granger <ged@FaerieMUD.org>
parents:
diff changeset
    36