File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -153,5 +153,36 @@ Listeners receive a
153153 This event is also dispatched when an exception is thrown by the command.
154154 It is then dispatched just after the ``ConsoleEvents::ERROR `` event.
155155 The exit code received in this case is the exception code.
156+
157+
158+ The ``ConsoleEvents::SIGNAL `` Event
159+ -----------------------------------
160+
161+ **Typical Purposes **: To perform some actions after the command execution was interrupted.
162+
163+ After the command has been interrupted, the ``ConsoleEvents::SIGNAL `` event is
164+ dispatched. It can be used to do any actions
165+ (to log or profile commands / to perform some cleanup tasks when quitting a command).
166+
167+ Listeners receive a
168+ :class: `Symfony\\ Component\\ Console\\ Event\\ ConsoleSignalEvent ` event::
169+
170+ use Symfony\Component\Console\ConsoleEvents;
171+ use Symfony\Component\Console\Event\ConsoleSignalEvent;
172+
173+ $dispatcher->addListener(ConsoleEvents::SIGNAL, function (ConsoleSignalEvent $event) {
174+
175+ // gets the signal number
176+ $signal = $event->getHandlingSignal();
177+
178+ if (\SIGINT === $signal) {
179+ echo "bye bye!";
180+ }
181+ });
182+
183+ .. versionadded :: 5.2
184+
185+ The ``ConsoleSignalEvent `` class was introduced in Symfony 5.2.
186+
156187
157188.. _`reserved exit codes` : https://www.tldp.org/LDP/abs/html/exitcodes.html
You can’t perform that action at this time.
0 commit comments