@@ -317,32 +317,55 @@ public function isTimerActive(TimerInterface $timer);
317317 public function futureTick (callable $ listener );
318318
319319 /**
320- * Registers a signal listener with the loop, which
321- * on it's turn registers it with a signal handler
322- * suitable for the loop implementation.
320+ * Register a listener to be notified when a signal has been caught by this process.
323321 *
324- * A listener can only be added once, any attempts
325- * to add it again will be ignored.
322+ * This is useful to catch user interrupt signals or shutdown signals from
323+ * tools like `supervisor` or `systemd`.
324+ *
325+ * The listener callback function MUST be able to accept a single parameter,
326+ * the signal added by this method or you MAY use a function which
327+ * has no parameters at all.
328+ *
329+ * The listener callback function MUST NOT throw an `Exception`.
330+ * The return value of the listener callback function will be ignored and has
331+ * no effect, so for performance reasons you're recommended to not return
332+ * any excessive data structures.
333+ *
334+ * ```php
335+ * $loop->addSignal(SIGINT, function (int $signal) {
336+ * echo 'Caught user interrupt signal' . PHP_EOL;
337+ * });
338+ * ```
326339 *
327340 * See also [example #4](examples).
328341 *
342+ * Signaling is only available on Unix-like platform, Windows isn't
343+ * supported due to operating system limitations.
344+ * This method may throw a `BadMethodCallException` if signals aren't
345+ * supported on this platform, for example when required extensions are
346+ * missing.
347+ *
348+ * **Note: A listener can only be added once to the same signal, any
349+ * attempts to add it more then once will be ignored.**
350+ *
329351 * @param int $signal
330352 * @param callable $listener
331353 *
332- * @throws \BadMethodCallException when signals
333- * aren't supported by the loop, e.g. when required
334- * extensions are missing.
354+ * @throws \BadMethodCallException when signals aren't supported on this
355+ * platform, for example when required extensions are missing.
335356 *
336357 * @return void
337358 */
338359 public function addSignal ($ signal , callable $ listener );
339360
340361 /**
341- * Removed previous registered signal listener from
342- * the loop, which on it's turn removes it from the
343- * underlying signal handler.
362+ * Removes a previously added signal listener.
344363 *
345- * See also [example #4](examples).
364+ * ```php
365+ * $loop->removeSignal(SIGINT, $listener);
366+ * ```
367+ *
368+ * Any attempts to remove listeners that aren't registered will be ignored.
346369 *
347370 * @param int $signal
348371 * @param callable $listener
0 commit comments