Project

General

Profile

Feature #15277

at_exec

Added by marcandre (Marc-Andre Lafortune) almost 2 years ago. Updated 3 months ago.

Status:
Open
Priority:
Normal
Target version:
-
[ruby-core:89680]

Description

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.

Also available in: Atom PDF