Mercurial
comparison third_party/libuv/docs/src/signal.rst @ 160:948de3f54cea
[ThirdParty] Added libuv
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Wed, 14 Jan 2026 19:39:52 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 159:05cf9467a1c3 | 160:948de3f54cea |
|---|---|
| 1 | |
| 2 .. _signal: | |
| 3 | |
| 4 :c:type:`uv_signal_t` --- Signal handle | |
| 5 ======================================= | |
| 6 | |
| 7 Signal handles implement Unix style signal handling on a per-event loop bases. | |
| 8 | |
| 9 Windows notes | |
| 10 ------------- | |
| 11 | |
| 12 Reception of some signals is emulated: | |
| 13 | |
| 14 * SIGINT is normally delivered when the user presses CTRL+C. However, like | |
| 15 on Unix, it is not generated when terminal raw mode is enabled. | |
| 16 | |
| 17 * SIGBREAK is delivered when the user pressed CTRL + BREAK. | |
| 18 | |
| 19 * SIGHUP is generated when the user closes the console window. On SIGHUP the | |
| 20 program is given approximately 10 seconds to perform cleanup. After that | |
| 21 Windows will unconditionally terminate it. | |
| 22 | |
| 23 * SIGWINCH is raised whenever libuv detects that the console has been | |
| 24 resized. When a libuv app is running under a console emulator, or when a | |
| 25 32-bit libuv app is running on 64-bit system, SIGWINCH will be emulated. In | |
| 26 such cases SIGWINCH signals may not always be delivered in a timely manner. | |
| 27 For a writable :c:type:`uv_tty_t` handle libuv will only detect size changes | |
| 28 when the cursor is moved. When a readable :c:type:`uv_tty_t` handle is used, | |
| 29 resizing of the console buffer will be detected only if the handle is in raw | |
| 30 mode and is being read. | |
| 31 | |
| 32 * Watchers for other signals can be successfully created, but these signals | |
| 33 are never received. These signals are: `SIGILL`, `SIGABRT`, `SIGFPE`, `SIGSEGV`, | |
| 34 `SIGTERM` and `SIGKILL.` | |
| 35 | |
| 36 * Calls to raise() or abort() to programmatically raise a signal are | |
| 37 not detected by libuv; these will not trigger a signal watcher. | |
| 38 | |
| 39 .. versionchanged:: 1.15.0 SIGWINCH support on Windows was improved. | |
| 40 .. versionchanged:: 1.31.0 32-bit libuv SIGWINCH support on 64-bit Windows was | |
| 41 rolled back to old implementation. | |
| 42 | |
| 43 Unix notes | |
| 44 ---------- | |
| 45 | |
| 46 * SIGKILL and SIGSTOP are impossible to catch. | |
| 47 | |
| 48 * Handling SIGBUS, SIGFPE, SIGILL or SIGSEGV via libuv results into undefined behavior. | |
| 49 | |
| 50 * SIGABRT will not be caught by libuv if generated by `abort()`, e.g. through `assert()`. | |
| 51 | |
| 52 * On Linux SIGRT0 and SIGRT1 (signals 32 and 33) are used by the NPTL pthreads library to | |
| 53 manage threads. Installing watchers for those signals will lead to unpredictable behavior | |
| 54 and is strongly discouraged. Future versions of libuv may simply reject them. | |
| 55 | |
| 56 | |
| 57 Data types | |
| 58 ---------- | |
| 59 | |
| 60 .. c:type:: uv_signal_t | |
| 61 | |
| 62 Signal handle type. | |
| 63 | |
| 64 .. c:type:: void (*uv_signal_cb)(uv_signal_t* handle, int signum) | |
| 65 | |
| 66 Type definition for callback passed to :c:func:`uv_signal_start`. | |
| 67 | |
| 68 | |
| 69 Public members | |
| 70 ^^^^^^^^^^^^^^ | |
| 71 | |
| 72 .. c:member:: int uv_signal_t.signum | |
| 73 | |
| 74 Signal being monitored by this handle. Readonly. | |
| 75 | |
| 76 .. seealso:: The :c:type:`uv_handle_t` members also apply. | |
| 77 | |
| 78 | |
| 79 API | |
| 80 --- | |
| 81 | |
| 82 .. c:function:: int uv_signal_init(uv_loop_t* loop, uv_signal_t* signal) | |
| 83 | |
| 84 Initialize the handle. | |
| 85 | |
| 86 .. c:function:: int uv_signal_start(uv_signal_t* signal, uv_signal_cb cb, int signum) | |
| 87 | |
| 88 Start the handle with the given callback, watching for the given signal. | |
| 89 | |
| 90 .. c:function:: int uv_signal_start_oneshot(uv_signal_t* signal, uv_signal_cb cb, int signum) | |
| 91 | |
| 92 .. versionadded:: 1.12.0 | |
| 93 | |
| 94 Same functionality as :c:func:`uv_signal_start` but the signal handler is reset the moment | |
| 95 the signal is received. | |
| 96 | |
| 97 .. c:function:: int uv_signal_stop(uv_signal_t* signal) | |
| 98 | |
| 99 Stop the handle, the callback will no longer be called. | |
| 100 | |
| 101 .. seealso:: The :c:type:`uv_handle_t` API functions also apply. |