Class: ShellElf::Job
- Inherits:
-
Object
- Object
- ShellElf::Job
- Defined in:
- lib/shell_elf/job.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(command) ⇒ Job
constructor
A new instance of Job.
- #success? ⇒ Boolean
Constructor Details
#initialize(command) ⇒ Job
Returns a new instance of Job.
9 10 11 |
# File 'lib/shell_elf/job.rb', line 9 def initialize(command) @command = command end |
Class Method Details
.execute(command) ⇒ Object
4 5 6 |
# File 'lib/shell_elf/job.rb', line 4 def execute(command) new(command).execute end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/shell_elf/job.rb', line 13 def execute escaped_command = Escape.shell_command(@command) ShellElf.logger.info(escaped_command) fork do # this way we can detach from the shell session # so the child process doesn't receive SIGINTs Process.setsid exec(escaped_command) end Process.wait(-1) @success = $? == 0 ShellElf.logger.debug(@success ? 'success' : 'failed') self end |
#success? ⇒ Boolean
28 29 30 |
# File 'lib/shell_elf/job.rb', line 28 def success? @success end |