Advertisement
Guest User

Untitled

a guest
Nov 9th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.50 KB | None | 0 0
  1. class Jobs
  2.   MANAGER = new
  3.  
  4.   def self.manager
  5.     MANAGER
  6.   end
  7.  
  8.   def initialize(@fg : Process? = nil)
  9.   end
  10.  
  11.   property fg
  12. end
  13.  
  14. Signal::INT.trap do |x|
  15.   if !Jobs.manager.fg
  16.     puts "Got SIGINT, but there is no process in the foreground."
  17.   else
  18.     Jobs.manager.fg.kill(Signal::INT)
  19.   end
  20. end
  21.  
  22. Gives the following error:
  23. Error in src/crysh.cr:27: undefined method 'kill' for Nil (compile-time type is (Process | Nil))
  24.  
  25.     Jobs.manager.fg.kill(Signal::INT)
  26.                     ^~~~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement