Project

General

Profile

Actions

Feature #15277

open

at_exec

Added by marcandre (Marc-Andre Lafortune) about 6 years ago. Updated 8 months ago.

Status:
Assigned
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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0