[#114703] [Ruby master Bug#19875] Ruby 2.7 -> 3.1 Performance regression in String#count — "iz (Illia Zub) via ruby-core" <ruby-core@...>

Issue #19875 has been reported by iz (Illia Zub).

18 messages 2023/09/12

[#114774] [Ruby master Feature#19884] Make Safe Navigation Operator work on classes — "p8 (Petrik de Heus) via ruby-core" <ruby-core@...>

Issue #19884 has been reported by p8 (Petrik de Heus).

13 messages 2023/09/15

[#114796] [Ruby master Feature#19889] Let `Kernel.#require` search for files relative to the current working directory for non ./, ../ relative paths — "sawa (Tsuyoshi Sawada) via ruby-core" <ruby-core@...>

Issue #19889 has been reported by sawa (Tsuyoshi Sawada).

6 messages 2023/09/18

[#114803] [Ruby master Bug#19890] File#realine(chomp: true) slower/more allocations than readline.chomp! — "segiddins (Samuel Giddins) via ruby-core" <ruby-core@...>

Issue #19890 has been reported by segiddins (Samuel Giddins).

12 messages 2023/09/18

[#114817] [Ruby master Bug#19892] Build failure with 8f1b688177 — "vo.x (Vit Ondruch) via ruby-core" <ruby-core@...>

Issue #19892 has been reported by vo.x (Vit Ondruch).

8 messages 2023/09/19

[#114915] [Ruby master Feature#19905] Introduce `Queue#peek` — "hi@... (Joao Fernandes) via ruby-core" <ruby-core@...>

Issue #19905 has been reported by [email protected] (Joao Fernandes).

8 messages 2023/09/28

[ruby-core:114865] [Ruby master Bug#18911] Process._fork hook point is not called when Process.daemon is used

From: "Dan0042 (Daniel DeLorme) via ruby-core" <ruby-core@...>
Date: 2023-09-21 18:30:17 UTC
List: ruby-core #114865
Issue #18911 has been updated by Dan0042 (Daniel DeLorme).


Note for future readers coming here from the `Process._fork` documentation.
If you need to restart threads, you should override both `_fork` and `daemon`

```ruby
module RestartWatcherThread
  def _fork
    pid = super
    restart_thread if pid == 0
    pid
  end
  def daemon(...)
    super.tap{ restart_thread }
  end
  prepend_features(Process.singleton_class)
end
```


----------------------------------------
Bug #18911: Process._fork hook point is not called when Process.daemon is used
https://bugs.ruby-lang.org/issues/18911#change-104713

* Author: ivoanjo (Ivo Anjo)
* Status: Closed
* Priority: Normal
* Assignee: akr (Akira Tanaka)
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Hello there! I'm working at Datadog [on the `ddtrace` gem](https://github.com/DataDog/dd-trace-rb), and we need to hook into fork operations to make sure that our products work correctly/automatically even in environments that fork.

As part as #17795 a new `Process._fork` method was added to allow libraries and frameworks to easily hook into fork operations. I was investigating its use in `ddtrace` and noticed the following gap: the `Process.daemon` API internally makes use of `fork`, but the new hook point is not called for that API.

Testcase:

```ruby
puts RUBY_DESCRIPTION

module ForkHook
  def _fork(*args)
    puts "  #{Process.pid} Before fork!"
    res = super
    puts "  #{Process.pid} After fork!"
    res
  end
end

Process.singleton_class.prepend(ForkHook)

puts "#{Process.pid} Regular fork:"

fork { exit }
Process.wait

puts "#{Process.pid} Process.daemon:"

Process.daemon(nil, true)

puts "#{Process.pid} Finishing!"
```

Testcase output:

```
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]
48136 Regular fork: # <-- original process
  48136 Before fork!
  48136 After fork! # <-- original process
  48137 After fork! # <-- child process
48136 Process.daemon: # <-- original process
48139 Finishing! # <-- forks and pid changes, but the hook isn't called
```

This was surprising to me since the advantage of this hook point would not not needing to hook into the many other places where `fork` can get called from.

Thanks a lot :)



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- [email protected]
 To unsubscribe send an email to [email protected]
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

In This Thread

Prev Next