traceroute: fix help text to not show -6 when traceroute6 is off
[oweals/busybox.git] / libbb / xfuncs_printf.c
index 345c8421915519ef1e7941738583da2ac84e8c21..644134a0e01392fd976a03e2dd1815793bd155fe 100644 (file)
@@ -140,6 +140,15 @@ int FAST_FUNC xopen(const char *pathname, int flags)
        return xopen3(pathname, flags, 0666);
 }
 
+/* Die if we can't open an existing file readonly with O_NONBLOCK
+ * and return the fd.
+ * Note that for ioctl O_RDONLY is sufficient.
+ */
+int FAST_FUNC xopen_nonblocking(const char *pathname)
+{
+       return xopen(pathname, O_RDONLY | O_NONBLOCK);
+}
+
 // Warn if we can't open a file and return a fd.
 int FAST_FUNC open3_or_warn(const char *pathname, int flags, int mode)
 {
@@ -246,12 +255,9 @@ void FAST_FUNC die_if_ferror_stdout(void)
        die_if_ferror(stdout, bb_msg_standard_output);
 }
 
-// Die with an error message if we have trouble flushing stdout.
-void FAST_FUNC xfflush_stdout(void)
+int FAST_FUNC fflush_all(void)
 {
-       if (fflush(stdout)) {
-               bb_perror_msg_and_die(bb_msg_standard_output);
-       }
+       return fflush(NULL);
 }
 
 
@@ -267,9 +273,9 @@ int FAST_FUNC bb_putchar(int ch)
  * then close that file. */
 void FAST_FUNC xprint_and_close_file(FILE *file)
 {
-       fflush(stdout);
+       fflush_all();
        // copyfd outputs error messages for us.
-       if (bb_copyfd_eof(fileno(file), 1) == -1)
+       if (bb_copyfd_eof(fileno(file), STDOUT_FILENO) == -1)
                xfunc_die();
 
        fclose(file);