]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Move valid_fd_012() from string.c to fd.c.
authorAndre Noll <maan@systemlinux.org>
Mon, 4 Aug 2008 15:11:41 +0000 (17:11 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 4 Aug 2008 15:11:41 +0000 (17:11 +0200)
fd.c
fd.h
string.c
string.h

diff --git a/fd.c b/fd.c
index 58851723978fb3c9856f87aa35d65a7141c162d7..8fc1abad19057bd724f26a25dca2ddb3ba5003ee 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -426,3 +426,24 @@ again:
                goto again;
        return ret;
 }
+
+/**
+ * Ensure that file descriptors 0, 1, and 2 are valid.
+ *
+ * Common approach that opens /dev/null until it gets a file descriptor greater
+ * than two.
+ *
+ * \sa okir's Black Hats Manual.
+ */
+void valid_fd_012(void)
+{
+       while (1) {
+               int fd = open("/dev/null", O_RDWR);
+               if (fd < 0)
+                       exit(EXIT_FAILURE);
+               if (fd > 2) {
+                       close(fd);
+                       break;
+               }
+       }
+}
diff --git a/fd.h b/fd.h
index 22141be2d79a7451188f0d6986b772368248ff71..ae692b4fbe00dad1efc33237700d41f4524c825f 100644 (file)
--- a/fd.h
+++ b/fd.h
@@ -24,3 +24,4 @@ int mmap_full_file(const char *filename, int open_mode, void **map,
        size_t *size, int *fd_ptr);
 int para_munmap(void *start, size_t length);
 int write_ok(int fd);
+void valid_fd_012(void);
index 752fb8f945d1a381b7b7af4e65ed56b646df8d47..c73ec1e6d70377b24bafcb9462035067099fc945 100644 (file)
--- a/string.c
+++ b/string.c
@@ -327,27 +327,6 @@ __must_check unsigned split_args(char *args, char *** const argv_ptr, const char
        return n;
 }
 
-/**
- * Ensure that file descriptors 0, 1, and 2 are valid.
- *
- * Common approach that opens /dev/null until it gets a file descriptor greater
- * than two.
- *
- * \sa okir's Black Hats Manual.
- */
-void valid_fd_012(void)
-{
-       while (1) {
-               int fd = open("/dev/null", O_RDWR);
-               if (fd < 0)
-                       exit(EXIT_FAILURE);
-               if (fd > 2) {
-                       close(fd);
-                       break;
-               }
-       }
-}
-
 /**
  * Get the own hostname.
  *
index 561ff4e8705c4d20baf0b01999503f725cadb820..e91a140be0ae6c8dc2371e027d5326d470209f68 100644 (file)
--- a/string.h
+++ b/string.h
@@ -40,7 +40,6 @@ __must_check __malloc char *para_logname(void);
 __must_check __malloc char *para_homedir(void);
 __must_check unsigned split_args(char *args, char *** const argv_ptr, const char *delim);
 __malloc char *para_hostname(void);
-void valid_fd_012(void);
 __printf_2_3 int para_printf(struct para_buffer *b, const char *fmt, ...);
 /** Used for for_each_line() and for_each_line_ro(). */
 typedef int line_handler_t(char *, void *);