source: MondoRescue/branches/2.2.9/mindi-busybox/debianutils/pipe_progress.c@ 2725

Last change on this file since 2725 was 2725, checked in by Bruno Cornec, 13 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File size: 852 bytes
RevLine 
[821]1/* vi: set sw=4 ts=4: */
2/*
3 * Monitor a pipe with a simple progress display.
4 *
5 * Copyright (C) 2003 by Rob Landley <rob@landley.net>, Joey Hess
6 *
[2725]7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
[821]8 */
[1765]9#include "libbb.h"
[821]10
11#define PIPE_PROGRESS_SIZE 4096
12
13/* Read a block of data from stdin, write it to stdout.
14 * Activity is indicated by a '.' to stderr
15 */
[2725]16int pipe_progress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
17int pipe_progress_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
[821]18{
[2725]19 char buf[PIPE_PROGRESS_SIZE];
[821]20 time_t t = time(NULL);
[2725]21 int len;
[821]22
[2725]23 while ((len = safe_read(STDIN_FILENO, buf, PIPE_PROGRESS_SIZE)) > 0) {
[821]24 time_t new_time = time(NULL);
25 if (new_time != t) {
26 t = new_time;
[2725]27 bb_putchar_stderr('.');
[821]28 }
[2725]29 full_write(STDOUT_FILENO, buf, len);
[821]30 }
31
[2725]32 bb_putchar_stderr('\n');
[821]33
34 return 0;
35}
Note: See TracBrowser for help on using the repository browser.