Class: Dia::Application
- Inherits:
-
Object
- Object
- Dia::Application
- Includes:
- SharedFeatures
- Defined in:
- lib/dia/application.rb
Overview
The Application class provides an interface for executing an application in a sandbox.
Instance Attribute Summary
Attributes included from SharedFeatures
Instance Method Summary collapse
-
#initialize(profile, app) ⇒ Application
constructor
A new instance of Application.
-
#run ⇒ Fixnum
This method will spawn a child process, and execute an application in a sandbox.
-
#run_nonblock ⇒ Fixnum
An identical but non-blocking form of #run.
Methods included from SharedFeatures
#exit_status, #running?, #terminate
Constructor Details
#initialize(profile, app) ⇒ Application
Returns a new instance of Application.
16 17 18 19 20 21 22 |
# File 'lib/dia/application.rb', line 16 def initialize(profile, app) @profile = profile @app = app raise(ArgumentError, "It is not possible to launch an application with the " \ "Dia::Profiles::NO_OS_SERVICES profile at this time") \ if @profile == Dia::Profiles::NO_OS_SERVICES end |
Instance Method Details
#run ⇒ Fixnum
This method will spawn a child process, and execute an application in a sandbox.
31 32 33 34 35 36 37 38 39 |
# File 'lib/dia/application.rb', line 31 def run @pid = fork do initialize_sandbox exec(@app) end _, @exit_status = Process.wait2(@pid) @pid end |
#run_nonblock ⇒ Fixnum
An identical but non-blocking form of #run.
43 44 45 46 47 48 49 50 51 |
# File 'lib/dia/application.rb', line 43 def run_nonblock @pid = fork do initialize_sandbox exec(@app) end @exit_status = Process.detach(@pid) @pid end |