Project

General

Profile

Feature #5945

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

I'd like to propose a enhancement to `at_exit`. at_exit.  
 It would be nice if you could stop a `at_exit` at_exit handler from running in subprocesses.  
 You can do this manually with this code: 

 ```ruby 
 parent = Process.pid 

 at_exit do  
   if parent == Process.pid  
      # … 
   
    end 
 end 
 ``` 

 You can also do it by bypassing handlers: 

 ```ruby 
 at_exit do 
   # … 
 end 

 fork do  
   exit! 
 end 
 ``` 

 But it would be nice if I could do: 

 ```ruby 
 at_exit(false) do 
   # … 
 end 
 ``` 

 The first approach is kind of ugly, and the second approach isn't sustainable if code outside  
 your control can `fork(…)` fork(…) without calling `exit!`. exit!. 

Back