Issue #595 has been updated by ioquatix (Samuel Williams).

Assignee changed from ko1 (Koichi Sasada) to ioquatix (Samuel Williams)

While it's not possible unless we invoke functionality from the GC, if/when we merge https://bugs.ruby-lang.org/issues/10344 it should become simple to do the following

```
while fiber.alive?
    fiber.raise(Exception, "Time to die")
end
```

This would guarantee all ensure blocks are executed.

In theory you could implement `fiber.kill` which does this, and then invoke that from the GC in the finaliser.. but might be unexpected for user.

----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-75792

* Author: ko1 (Koichi Sasada)
* Status: Assigned
* Priority: Normal
* Assignee: ioquatix (Samuel Williams)
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------

 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.

``` 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
```


---Files--------------------------------
ensure_fiber.patch (2.12 KB)
ensure_fiber2.patch (7.57 KB)


-- 
https://bugs.ruby-lang.org/