forked from enlightenment/efl
ecore: use new API eina_file_close_on_exec.
This commit is contained in:
parent
a2094567c9
commit
712f7e878b
|
@ -165,7 +165,7 @@ _timer_tick_core(void *data EINA_UNUSED, Ecore_Thread *thread)
|
||||||
|
|
||||||
#ifdef HAVE_EPOLL
|
#ifdef HAVE_EPOLL
|
||||||
pollfd = epoll_create(1);
|
pollfd = epoll_create(1);
|
||||||
if (pollfd >= 0) _ecore_fd_close_on_exec(pollfd);
|
if (pollfd >= 0) eina_file_close_on_exec(pollfd, EINA_TRUE);
|
||||||
|
|
||||||
#if defined(TFD_NONBLOCK) && defined(TFD_CLOEXEC)
|
#if defined(TFD_NONBLOCK) && defined(TFD_CLOEXEC)
|
||||||
timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||||
|
@ -173,7 +173,7 @@ _timer_tick_core(void *data EINA_UNUSED, Ecore_Thread *thread)
|
||||||
if (timerfd < 0)
|
if (timerfd < 0)
|
||||||
{
|
{
|
||||||
timerfd = timerfd_create(CLOCK_MONOTONIC, 0);
|
timerfd = timerfd_create(CLOCK_MONOTONIC, 0);
|
||||||
if (timerfd >= 0) _ecore_fd_close_on_exec(timerfd);
|
if (timerfd >= 0) eina_file_close_on_exec(timerfd, EINA_TRUE);
|
||||||
}
|
}
|
||||||
if (timerfd < 0)
|
if (timerfd < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -339,7 +339,7 @@ _impl_ecore_exe_efl_object_finalize(Eo *obj, Ecore_Exe_Data *exe)
|
||||||
{
|
{
|
||||||
/* Setup the status pipe. */
|
/* Setup the status pipe. */
|
||||||
E_NO_ERRNO(result, close(statusPipe[0]), ok);
|
E_NO_ERRNO(result, close(statusPipe[0]), ok);
|
||||||
E_IF_NO_ERRNO(result, fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC), ok) /* close on exec shows success */
|
E_IF_NO_ERRNO(result, eina_file_close_on_exec(statusPipe[1], EINA_TRUE), ok) /* close on exec shows success */
|
||||||
{
|
{
|
||||||
/* Run the actual command. */
|
/* Run the actual command. */
|
||||||
_ecore_exe_exec_it(exe_cmd, flags); /* no return */
|
_ecore_exe_exec_it(exe_cmd, flags); /* no return */
|
||||||
|
@ -422,12 +422,12 @@ _impl_ecore_exe_efl_object_finalize(Eo *obj, Ecore_Exe_Data *exe)
|
||||||
O_NONBLOCK), ok) {
|
O_NONBLOCK), ok) {
|
||||||
}
|
}
|
||||||
E_IF_NO_ERRNO(result,
|
E_IF_NO_ERRNO(result,
|
||||||
fcntl(exe->child_fd_error, F_SETFD,
|
eina_file_close_on_exec(exe->child_fd_error, EINA_TRUE),
|
||||||
FD_CLOEXEC), ok) {
|
ok) {
|
||||||
}
|
}
|
||||||
E_IF_NO_ERRNO(result,
|
E_IF_NO_ERRNO(result,
|
||||||
fcntl(exe->child_fd_error_x, F_SETFD,
|
eina_file_close_on_exec(exe->child_fd_error_x, EINA_TRUE),
|
||||||
FD_CLOEXEC), ok) {
|
ok) {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
exe->error_fd_handler =
|
exe->error_fd_handler =
|
||||||
|
@ -446,12 +446,12 @@ _impl_ecore_exe_efl_object_finalize(Eo *obj, Ecore_Exe_Data *exe)
|
||||||
O_NONBLOCK), ok) {
|
O_NONBLOCK), ok) {
|
||||||
}
|
}
|
||||||
E_IF_NO_ERRNO(result,
|
E_IF_NO_ERRNO(result,
|
||||||
fcntl(exe->child_fd_read, F_SETFD,
|
eina_file_close_on_exec(exe->child_fd_read, EINA_TRUE),
|
||||||
FD_CLOEXEC), ok) {
|
ok) {
|
||||||
}
|
}
|
||||||
E_IF_NO_ERRNO(result,
|
E_IF_NO_ERRNO(result,
|
||||||
fcntl(exe->child_fd_read_x, F_SETFD,
|
eina_file_close_on_exec(exe->child_fd_read_x, EINA_TRUE),
|
||||||
FD_CLOEXEC), ok) {
|
ok) {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
exe->read_fd_handler =
|
exe->read_fd_handler =
|
||||||
|
@ -470,12 +470,12 @@ _impl_ecore_exe_efl_object_finalize(Eo *obj, Ecore_Exe_Data *exe)
|
||||||
O_NONBLOCK), ok) {
|
O_NONBLOCK), ok) {
|
||||||
}
|
}
|
||||||
E_IF_NO_ERRNO(result,
|
E_IF_NO_ERRNO(result,
|
||||||
fcntl(exe->child_fd_write, F_SETFD,
|
eina_file_close_on_exec(exe->child_fd_write, EINA_TRUE),
|
||||||
FD_CLOEXEC), ok) {
|
ok) {
|
||||||
}
|
}
|
||||||
E_IF_NO_ERRNO(result,
|
E_IF_NO_ERRNO(result,
|
||||||
fcntl(exe->child_fd_write_x, F_SETFD,
|
eina_file_close_on_exec(exe->child_fd_write_x, EINA_TRUE),
|
||||||
FD_CLOEXEC), ok) {
|
ok) {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
exe->write_fd_handler =
|
exe->write_fd_handler =
|
||||||
|
|
|
@ -326,21 +326,6 @@ static gboolean _ecore_glib_idle_enterer_called;
|
||||||
static gboolean ecore_fds_ready;
|
static gboolean ecore_fds_ready;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
|
||||||
_ecore_fd_close_on_exec(int fd)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_FCNTL
|
|
||||||
int flags;
|
|
||||||
|
|
||||||
flags = fcntl(fd, F_GETFD);
|
|
||||||
if (flags == -1) return;
|
|
||||||
flags |= FD_CLOEXEC;
|
|
||||||
if (fcntl(fd, F_SETFD, flags) == -1) return;
|
|
||||||
#else
|
|
||||||
(void) fd;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef EFL_EXTRA_SANITY_CHECKS
|
#ifdef EFL_EXTRA_SANITY_CHECKS
|
||||||
static inline void
|
static inline void
|
||||||
_ecore_fd_valid(void)
|
_ecore_fd_valid(void)
|
||||||
|
@ -1042,7 +1027,7 @@ _ecore_main_loop_init(void)
|
||||||
if ((epoll_fd < 0) && HAVE_EPOLL)
|
if ((epoll_fd < 0) && HAVE_EPOLL)
|
||||||
WRN("Failed to create epoll fd!");
|
WRN("Failed to create epoll fd!");
|
||||||
epoll_pid = getpid();
|
epoll_pid = getpid();
|
||||||
_ecore_fd_close_on_exec(epoll_fd);
|
eina_file_close_on_exec(epoll_fd, EINA_TRUE);
|
||||||
|
|
||||||
/* add polls on all our file descriptors */
|
/* add polls on all our file descriptors */
|
||||||
Ecore_Fd_Handler *fdh;
|
Ecore_Fd_Handler *fdh;
|
||||||
|
@ -1148,7 +1133,7 @@ _ecore_main_loop_init(void)
|
||||||
WRN("failed to create timer fd!");
|
WRN("failed to create timer fd!");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_ecore_fd_close_on_exec(timer_fd);
|
eina_file_close_on_exec(timer_fd, EINA_TRUE);
|
||||||
ecore_timer_fd.fd = timer_fd;
|
ecore_timer_fd.fd = timer_fd;
|
||||||
ecore_timer_fd.events = G_IO_IN;
|
ecore_timer_fd.events = G_IO_IN;
|
||||||
ecore_timer_fd.revents = 0;
|
ecore_timer_fd.revents = 0;
|
||||||
|
|
|
@ -360,15 +360,15 @@ ecore_pipe_full_add(Ecore_Pipe_Cb handler,
|
||||||
p->data = data;
|
p->data = data;
|
||||||
|
|
||||||
if (!read_survive_fork)
|
if (!read_survive_fork)
|
||||||
_ecore_fd_close_on_exec(fd_read);
|
eina_file_close_on_exec(fd_read, EINA_TRUE);
|
||||||
if (!write_survive_fork)
|
if (!write_survive_fork)
|
||||||
_ecore_fd_close_on_exec(fd_write);
|
eina_file_close_on_exec(fd_write, EINA_TRUE);
|
||||||
|
|
||||||
#if defined(HAVE_SYS_EPOLL_H) && defined(HAVE_SYS_TIMERFD_H)
|
#if defined(HAVE_SYS_EPOLL_H) && defined(HAVE_SYS_TIMERFD_H)
|
||||||
struct epoll_event pollev = { 0 };
|
struct epoll_event pollev = { 0 };
|
||||||
p->pollfd = epoll_create(1);
|
p->pollfd = epoll_create(1);
|
||||||
p->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
p->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||||
_ecore_fd_close_on_exec(p->pollfd);
|
eina_file_close_on_exec(p->pollfd, EINA_TRUE);
|
||||||
|
|
||||||
pollev.data.ptr = (void *)(uintptr_t)(p->fd_read);
|
pollev.data.ptr = (void *)(uintptr_t)(p->fd_read);
|
||||||
pollev.events = EPOLLIN;
|
pollev.events = EPOLLIN;
|
||||||
|
|
|
@ -213,8 +213,6 @@ Ecore_Fd_Handler *
|
||||||
Eina_Bool is_file);
|
Eina_Bool is_file);
|
||||||
void *_ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
|
void *_ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
|
||||||
|
|
||||||
void _ecore_fd_close_on_exec(int fd);
|
|
||||||
|
|
||||||
void _ecore_main_shutdown(void);
|
void _ecore_main_shutdown(void);
|
||||||
|
|
||||||
#if defined (_WIN32) || defined (__lv2ppu__) || defined (HAVE_EXOTIC)
|
#if defined (_WIN32) || defined (__lv2ppu__) || defined (HAVE_EXOTIC)
|
||||||
|
|
|
@ -69,18 +69,7 @@ _efl_io_closer_fd_efl_io_closer_close_on_exec_set(Eo *o, Efl_Io_Closer_Fd_Data *
|
||||||
* already set!
|
* already set!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = fcntl(fd, F_GETFD);
|
if (!eina_file_close_on_exec(fd, close_on_exec))
|
||||||
if (flags < 0)
|
|
||||||
{
|
|
||||||
ERR("fcntl(%d, F_GETFD): %s", fd, strerror(errno));
|
|
||||||
pd->close_on_exec = old;
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
if (close_on_exec)
|
|
||||||
flags |= FD_CLOEXEC;
|
|
||||||
else
|
|
||||||
flags &= (~FD_CLOEXEC);
|
|
||||||
if (fcntl(fd, F_SETFD, flags) < 0)
|
|
||||||
{
|
{
|
||||||
ERR("fcntl(%d, F_SETFD, %#x): %s", fd, flags, strerror(errno));
|
ERR("fcntl(%d, F_SETFD, %#x): %s", fd, flags, strerror(errno));
|
||||||
pd->close_on_exec = old;
|
pd->close_on_exec = old;
|
||||||
|
|
Loading…
Reference in New Issue