From: daniele@... Date: 2020-05-25T01:09:26+00:00 Subject: [ruby-core:98507] [Ruby master Feature#15277] at_exec Issue #15277 has been updated by vihai (Daniele Orlandi). I would like to add a use-case that I'm encountering right now. I would like to call prctl(PR_SET_PDEATHSIG, ...) in order to ensure that a spawned process is always killed regardless of how cleanly the parent process exits. I couldn't do this in the parent because fork(2) clears such setting so I must be able to invoke prctl between fork and exec. An alternative solution would be to add a callback to spawn's options to be called before exec. ---------------------------------------- Feature #15277: at_exec https://bugs.ruby-lang.org/issues/15277#change-85784 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- There's currently no easy way to have code executed before a subsequent call to `exec`. One has to monkey-patch the builtin method. I'd like to propose a new method `at_exec` that would be very similar to `at_exit`, except that the callbacks are triggered before the current process is replaced by the external command. ``` # This would output "Hello", "Bye", and "Foo" at_exec { puts "Bye!" } puts "Hello" exec "echo Foo" ``` Use case: we roll our own in `DeepCover`. Some test suites will call `exec`, and we need to store our counters before that happens. -- https://bugs.ruby-lang.org/ Unsubscribe: