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;
+ }
+ }
+}
size_t *size, int *fd_ptr);
int para_munmap(void *start, size_t length);
int write_ok(int fd);
+void valid_fd_012(void);
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.
*
__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 *);