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