GLib.closefrom (original) (raw)
Function
GLibclosefrom
since: 2.80
Declaration [src]
int
g_closefrom (
int lowfd
)
Description [src]
Close every file descriptor equal to or greater than lowfd
.
Typically lowfd
will be 3, to leave standard input, standard output and standard error open.
This is the same as Linux close_range (lowfd, ~0U, 0)
, but portable to other OSs and to older versions of Linux. Equivalently, it is the same as BSD closefrom (lowfd)
, but portable, and async-signal-safe on all OSs.
This function is async-signal safe, making it safe to call from a signal handler or a GSpawnChildSetupFunc, as long as lowfd
is non-negative. See signal(7) andsignal-safety(7) for more details.
Available since: 2.80
Parameters
lowfd
Type: int
Minimum fd to close, which must be non-negative.
Return value
Type: int
0 on success, -1 with errno set on error.