summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2014-10-15 20:53:45 +0300
committerEric Koegel <eric.koegel@gmail.com>2014-10-15 20:53:45 +0300
commit2bba10e158144211f2877d2d9044699bad656fd5 (patch)
tree4d4aed0eee4620258a8cf3e46d9bed38f284dc07
parent0358269de147ea7a05c32a1c495e73ea373cb4f4 (diff)
downloadConsoleKit2-2bba10e158144211f2877d2d9044699bad656fd5.tar.gz
Use g_io_add_watch for the named pipe
-rw-r--r--src/ck-inhibit.c12
-rw-r--r--src/test-inhibit.c3
2 files changed, 10 insertions, 5 deletions
diff --git a/src/ck-inhibit.c b/src/ck-inhibit.c
index 47a49b1..6f5ab71 100644
--- a/src/ck-inhibit.c
+++ b/src/ck-inhibit.c
@@ -257,7 +257,7 @@ close_named_pipe (CkInhibit *inhibit)
}
static gboolean
-cb_named_pipe_close (gint fd,
+cb_named_pipe_close (GIOChannel *source,
GIOCondition condition,
gpointer user_data)
{
@@ -291,6 +291,7 @@ static gint
create_named_pipe (CkInhibit *inhibit)
{
CkInhibitPrivate *priv;
+ GIOChannel *io;
g_return_val_if_fail (CK_IS_INHIBIT (inhibit), -1);
@@ -324,10 +325,11 @@ create_named_pipe (CkInhibit *inhibit)
}
/* Monitor the named pipe */
- priv->fd_source = g_unix_fd_add (priv->named_pipe,
- G_IO_HUP,
- (GUnixFDSourceFunc)cb_named_pipe_close,
- inhibit);
+ io = g_io_channel_unix_new (priv->named_pipe);
+ priv->fd_source = g_io_add_watch (io,
+ G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ (GIOFunc)cb_named_pipe_close,
+ inhibit);
/* open the client side of the named pipe and return it */
return open(priv->named_pipe_path, O_WRONLY|O_CLOEXEC|O_NDELAY);
diff --git a/src/test-inhibit.c b/src/test-inhibit.c
index 951732e..0369ed3 100644
--- a/src/test-inhibit.c
+++ b/src/test-inhibit.c
@@ -95,6 +95,9 @@ test_close_inhibit_lock (void)
/* does it properly close? */
g_assert (g_close (fd, NULL));
+ /* verify we can't close it again */
+ g_assert_false (g_close (fd, NULL));
+
fd = -1;
}