evas: use new API eina_file_close_on_exec.

This commit is contained in:
Cedric BAIL 2017-04-18 16:55:03 -07:00
parent fed9ca47f2
commit a2094567c9
2 changed files with 3 additions and 30 deletions

View File

@ -73,26 +73,6 @@ static unsigned int async_queue_cache_max = 0;
static int _init_evas_event = 0;
Eina_Bool
_evas_fd_close_on_exec(int fd)
{
#ifdef HAVE_FCNTL
int flags;
flags = fcntl(fd, F_GETFD);
if (flags == -1)
return EINA_FALSE;
flags |= FD_CLOEXEC;
if (fcntl(fd, F_SETFD, flags) == -1)
return EINA_FALSE;
return EINA_TRUE;
#else
(void) fd;
return EINA_FALSE;
#endif
}
int
evas_async_events_init(void)
{
@ -109,8 +89,8 @@ evas_async_events_init(void)
return 0;
}
_evas_fd_close_on_exec(filedes[0]);
_evas_fd_close_on_exec(filedes[1]);
eina_file_close_on_exec(filedes[0], EINA_TRUE);
eina_file_close_on_exec(filedes[1], EINA_TRUE);
_fd_read = filedes[0];
_fd_write = filedes[1];

View File

@ -134,9 +134,6 @@ _server_connect(void)
{
int s, len;
struct sockaddr_un remote;
#ifdef HAVE_FCNTL
int flags;
#endif
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
{
@ -144,11 +141,7 @@ _server_connect(void)
return EINA_FALSE;
}
#ifdef HAVE_FCNTL
flags = fcntl(s, F_GETFD);
flags |= FD_CLOEXEC;
if (fcntl(s, F_SETFD, flags) < 0) ERR("can't set CLOEXEC on fd");
#endif
if (!eina_file_close_on_exec(s, EINA_TRUE)) ERR("can't set CLOEXEC on fd");
remote.sun_family = AF_UNIX;
_socket_path_set(remote.sun_path);