]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
add new wrapper around the pipe() syscall
authorRay Strode <rstrode@redhat.com>
Mon, 14 May 2007 19:00:50 +0000 (15:00 -0400)
committerRay Strode <rstrode@redhat.com>
Mon, 14 May 2007 19:00:50 +0000 (15:00 -0400)
src/ply-utils.c [new file with mode: 0644]
src/ply-utils.h

diff --git a/src/ply-utils.c b/src/ply-utils.c
new file mode 100644 (file)
index 0000000..81268b4
--- /dev/null
@@ -0,0 +1,35 @@
+#include <config.h>
+
+#include "ply-utils.h"
+
+bool 
+ply_open_unidirectional_pipe (int *sender_fd,
+                              int *receiver_fd)
+{
+  init pipe_fds[2];
+
+  assert (sender_fd != NULL);
+  assert (receiver_fd != NULL);
+
+  if (pipe (pipe_fds) < 0)
+    return false;
+
+  if (fcntl (pipe_fds[0], F_SETFD, O_NONBLOCK | FD_CLOEXEC) < 0)
+    {
+      close (pipe_fds[0]);
+      close (pipe_fds[1]);
+      return false;
+    }
+
+  if (fcntl (pipe_fds[1], F_SETFD, O_NONBLOCK | FD_CLOEXEC) < 0)
+    {
+      close (pipe_fds[0]);
+      close (pipe_fds[1]);
+      return false;
+    }
+
+  *sender_fd = pipe_fds[1];
+  *receiver_fd = pipe_fds[0];
+
+  return true;
+}
index ca82168613e72b44fdda9460ac052f60e2d79a43..3d7925ac5df5935f39bd2f517ca67cf1c4263772 100644 (file)
@@ -22,6 +22,8 @@
 #ifndef PLY_UTILS_H
 #define PLY_UTILS_H
 
+#include <stdint.h>
+
 #ifndef MIN
 #define MIN(a,b) ((a) <= (b)? (a) : (b))
 #endif
 #define CLAMP(a,b,c) (MIN (MAX ((a), (b)), (c)))
 #endif
 
+#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
+bool ply_open_unidirectional_pipe (int *sender_fd,
+                                   int *receiver_fd);
+#endif
+
 #endif /* PLY_UTILS_H */
 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */