mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
lib/util: added set_close_on_exec()
this was already in tevent_util.c, but library layering prevented us from using it in some other libraries
This commit is contained in:
parent
9782501f0b
commit
3b56f64923
@ -60,3 +60,21 @@ _PUBLIC_ int set_blocking(int fd, bool set)
|
||||
return fcntl( fd, F_SETFL, val);
|
||||
#undef FLAG_TO_SET
|
||||
}
|
||||
|
||||
|
||||
_PUBLIC_ bool set_close_on_exec(int fd)
|
||||
{
|
||||
#ifdef FD_CLOEXEC
|
||||
int val;
|
||||
|
||||
val = fcntl(fd, F_GETFD, 0);
|
||||
if (val >= 0) {
|
||||
val |= FD_CLOEXEC;
|
||||
val = fcntl(fd, F_SETFD, val);
|
||||
if (val != -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
@ -667,6 +667,11 @@ _PUBLIC_ bool directory_create_or_exist(const char *dname, uid_t uid,
|
||||
**/
|
||||
_PUBLIC_ int set_blocking(int fd, bool set);
|
||||
|
||||
/**
|
||||
set close on exec on a file descriptor if available
|
||||
**/
|
||||
_PUBLIC_ bool set_close_on_exec(int fd);
|
||||
|
||||
/**
|
||||
Sleep for a specified number of milliseconds.
|
||||
**/
|
||||
|
Loading…
Reference in New Issue
Block a user