From: Colin Walters Date: Mon, 2 May 2011 19:42:51 +0000 (-0400) Subject: GCancellable: Use g_unix_pipe_flags with FD_CLOEXEC X-Git-Tag: 2.29.4~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c078223b388939f3f7cb77bdaa8b60aad0713756;p=platform%2Fupstream%2Fglib.git GCancellable: Use g_unix_pipe_flags with FD_CLOEXEC The old code was creating a pipe and setting FD_CLOEXEC non-atomically. https://bugzilla.gnome.org/show_bug.cgi?id=649225 --- diff --git a/gio/gcancellable.c b/gio/gcancellable.c index 32f5081..5a078b4 100644 --- a/gio/gcancellable.c +++ b/gio/gcancellable.c @@ -194,34 +194,18 @@ g_cancellable_class_init (GCancellableClass *klass) #ifndef G_OS_WIN32 static void -set_fd_close_exec (int fd) -{ - int flags; - - flags = fcntl (fd, F_GETFD, 0); - if (flags != -1 && (flags & FD_CLOEXEC) == 0) - { - flags |= FD_CLOEXEC; - fcntl (fd, F_SETFD, flags); - } -} - - -static void g_cancellable_open_pipe (GCancellable *cancellable) { GCancellablePrivate *priv; priv = cancellable->priv; - if (pipe (priv->cancel_pipe) == 0) + if (g_unix_pipe_flags (priv->cancel_pipe, FD_CLOEXEC, NULL)) { /* Make them nonblocking, just to be sure we don't block * on errors and stuff */ g_unix_set_fd_nonblocking (priv->cancel_pipe[0], TRUE, NULL); g_unix_set_fd_nonblocking (priv->cancel_pipe[1], TRUE, NULL); - set_fd_close_exec (priv->cancel_pipe[0]); - set_fd_close_exec (priv->cancel_pipe[1]); if (priv->cancelled) {