add function fd_set_cloexec
parent
1bdc948909
commit
b2b933e5a7
4
HISTORY
4
HISTORY
|
|
@ -1,3 +1,7 @@
|
|||
|
||||
Version 1.27 2016-03-31
|
||||
* add function fd_set_cloexec
|
||||
|
||||
Version 1.26 2016-03-16
|
||||
* add logger parameter: compress_log_days_before
|
||||
|
||||
|
|
|
|||
|
|
@ -1392,11 +1392,11 @@ void set_log_level(char *pLogLevel)
|
|||
}
|
||||
}
|
||||
|
||||
int fd_add_flags(int fd, int adding_flags)
|
||||
int fcntl_add_flags(int fd, int get_cmd, int set_cmd, int adding_flags)
|
||||
{
|
||||
int flags;
|
||||
|
||||
flags = fcntl(fd, F_GETFL, 0);
|
||||
flags = fcntl(fd, get_cmd, 0);
|
||||
if (flags < 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
|
|
@ -1405,7 +1405,7 @@ int fd_add_flags(int fd, int adding_flags)
|
|||
return errno != 0 ? errno : EACCES;
|
||||
}
|
||||
|
||||
if (fcntl(fd, F_SETFL, flags | adding_flags) == -1)
|
||||
if (fcntl(fd, set_cmd, flags | adding_flags) == -1)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"fcntl fail, errno: %d, error info: %s.", \
|
||||
|
|
@ -1416,6 +1416,16 @@ int fd_add_flags(int fd, int adding_flags)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int fd_add_flags(int fd, int adding_flags)
|
||||
{
|
||||
return fcntl_add_flags(fd, F_GETFL, F_SETFL, adding_flags);
|
||||
}
|
||||
|
||||
int fd_set_cloexec(int fd)
|
||||
{
|
||||
return fcntl_add_flags(fd, F_GETFD, F_SETFD, FD_CLOEXEC);
|
||||
}
|
||||
|
||||
int set_run_by(const char *group_name, const char *username)
|
||||
{
|
||||
#ifndef WIN32
|
||||
|
|
|
|||
|
|
@ -444,7 +444,17 @@ int fd_gets(int fd, char *buff, const int size, int once_bytes);
|
|||
*/
|
||||
int set_rlimit(int resource, const rlim_t value);
|
||||
|
||||
/** set non block mode
|
||||
/** fcntl add flags such as O_NONBLOCK or FD_CLOEXEC
|
||||
* parameters:
|
||||
* fd: the fd to set
|
||||
* get_cmd: the get command
|
||||
* set_cmd: the set command
|
||||
* adding_flags: the flags to add
|
||||
* return: error no , 0 success, != 0 fail
|
||||
*/
|
||||
int fcntl_add_flags(int fd, int get_cmd, int set_cmd, int adding_flags);
|
||||
|
||||
/** set fd flags such as O_NONBLOCK
|
||||
* parameters:
|
||||
* fd: the fd to set
|
||||
* adding_flags: the flags to add
|
||||
|
|
@ -459,6 +469,13 @@ int fd_add_flags(int fd, int adding_flags);
|
|||
*/
|
||||
#define set_nonblock(fd) fd_add_flags(fd, O_NONBLOCK)
|
||||
|
||||
/** set fd FD_CLOEXEC flags
|
||||
* parameters:
|
||||
* fd: the fd to set
|
||||
* return: error no , 0 success, != 0 fail
|
||||
*/
|
||||
int fd_set_cloexec(int fd);
|
||||
|
||||
/** set run by group and user
|
||||
* parameters:
|
||||
* group_name: the group name, can be NULL or empty
|
||||
|
|
|
|||
Loading…
Reference in New Issue