Skip to content

Instantly share code, notes, and snippets.

@znz znz/linux.txt Secret
Last active Jan 27, 2018

Embed
What would you like to do?
Process::Status
% ruby -ve 'begin;system(%q(ruby -e "exit(false)"), exception: true);rescue => e;p e;p Process.last_status;end'
ruby 2.6.0dev (2018-01-25 trunk 62034) [x86_64-linux]
#<RuntimeError: Command failed with status (1): ruby -e "exit(false)">
#<Process::Status: pid 32572 exit 1>
% ruby -ve 'begin;system(%q(ruby -e "Process.kill(:INT, Process.pid)"), exception: true);rescue;p $!;p $?;end'
ruby 2.6.0dev (2018-01-25 trunk 62034) [x86_64-linux]
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `kill': Interrupt
#<RuntimeError: Command failed with status (130): ruby -e "Process.kill(:INT, Process.pid)">
#<Process::Status: pid 32658 exit 130>
% ruby -ve 'begin;system(%q(ruby -e "Process.kill(:TERM, Process.pid)"), exception: true);rescue;p $!;p $?;end'
ruby 2.6.0dev (2018-01-25 trunk 62034) [x86_64-linux]
Terminated
#<RuntimeError: Command failed with status (143): ruby -e "Process.kill(:TERM, Process.pid)">
#<Process::Status: pid 1792 exit 143>
% ruby -ve 'begin;system(%q(ruby -e "Process.kill(:KILL, Process.pid)"), exception: true);rescue;p $!;p $?;end'
ruby 2.6.0dev (2018-01-25 trunk 62034) [x86_64-linux]
Killed
#<RuntimeError: Command failed with status (137): ruby -e "Process.kill(:KILL, Process.pid)">
#<Process::Status: pid 2115 exit 137>
% ruby -ve 'begin;system(%q(ruby -e "exit(false)"), exception: true);rescue => e;p e;p Process.last_status;end'
ruby 2.6.0dev (2018-01-25 trunk 62034) [x86_64-darwin16]
#<RuntimeError: Command failed with status (1): ruby -e "exit(false)">
#<Process::Status: pid 19457 exit 1>
% ruby -ve 'begin;system(%q(ruby -e "Process.kill(:INT, Process.pid)"), exception: true);rescue => e;p e;p Process.last_status;end'
ruby 2.6.0dev (2018-01-25 trunk 62034) [x86_64-darwin16]
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `kill': Interrupt
#<RuntimeError: Command failed with status (0): ruby -e "Process.kill(:INT, Process.pid)">
#<Process::Status: pid 19359 SIGINT (signal 2)>
% ruby -ve 'begin;system(%q(ruby -e "Process.kill(:TERM, Process.pid)"), exception: true);rescue => e;p e;p Process.last_status;end'
ruby 2.6.0dev (2018-01-25 trunk 62034) [x86_64-darwin16]
#<RuntimeError: Command failed with status (0): ruby -e "Process.kill(:TERM, Process.pid)">
#<Process::Status: pid 19392 SIGTERM (signal 15)>
% ruby -ve 'begin;system(%q(ruby -e "Process.kill(:KILL, Process.pid)"), exception: true);rescue => e;p e;p Process.last_status;end'
ruby 2.6.0dev (2018-01-25 trunk 62034) [x86_64-darwin16]
#<RuntimeError: Command failed with status (0): ruby -e "Process.kill(:KILL, Process.pid)">
#<Process::Status: pid 19424 SIGKILL (signal 9)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.