mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
gstdio: Document async-signal-safety of g_clear_fd and g_autofd
g_clear_fd wraps g_close and is async-signal-safe under essentially the same circumstances. If fd_ptr already pointed to a negative number, then g_clear_fd doesn't call g_close, and is still async-signal-safe. g_autofd passes a NULL error pointer to g_clear_fd, so it is async-signal-safe, as long as no programming error occurs. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
e231132fc3
commit
81130a6e3f
@ -1849,6 +1849,9 @@ g_close (gint fd,
|
|||||||
* stored in both %errno and @error. If this function succeeds,
|
* stored in both %errno and @error. If this function succeeds,
|
||||||
* %errno is undefined.
|
* %errno is undefined.
|
||||||
*
|
*
|
||||||
|
* This function is async-signal-safe if @error is %NULL and @fd_ptr
|
||||||
|
* points to either a negative number or a valid file descriptor.
|
||||||
|
*
|
||||||
* It is a programming error for @fd_ptr to point to a non-negative
|
* It is a programming error for @fd_ptr to point to a non-negative
|
||||||
* number that is not a valid file descriptor.
|
* number that is not a valid file descriptor.
|
||||||
*
|
*
|
||||||
@ -1902,6 +1905,9 @@ g_close (gint fd,
|
|||||||
* only supported on GCC and clang, and the variable must be initialized
|
* only supported on GCC and clang, and the variable must be initialized
|
||||||
* (to either a valid file descriptor or a negative number).
|
* (to either a valid file descriptor or a negative number).
|
||||||
*
|
*
|
||||||
|
* Using this macro is async-signal-safe if the constraints described above
|
||||||
|
* are met, so it can be used in a signal handler or after `fork()`.
|
||||||
|
*
|
||||||
* Any error from closing the file descriptor when it goes out of scope
|
* Any error from closing the file descriptor when it goes out of scope
|
||||||
* is ignored. Use g_clear_fd() if error-checking is required.
|
* is ignored. Use g_clear_fd() if error-checking is required.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user