Last change
on this file since 3889 was 3621, checked in by Bruno Cornec, 8 years ago |
New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.
|
File size:
1.2 KB
|
Rev | Line | |
---|
[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 | */
|
---|
[3621] | 9 | //config:config PIPE_PROGRESS
|
---|
| 10 | //config: bool "pipe_progress"
|
---|
| 11 | //config: default y
|
---|
| 12 | //config: help
|
---|
| 13 | //config: Display a dot to indicate pipe activity.
|
---|
[3232] | 14 |
|
---|
[3621] | 15 | //applet:IF_PIPE_PROGRESS(APPLET(pipe_progress, BB_DIR_BIN, BB_SUID_DROP))
|
---|
| 16 |
|
---|
| 17 | //kbuild:lib-$(CONFIG_PIPE_PROGRESS) += pipe_progress.o
|
---|
| 18 |
|
---|
[3232] | 19 | //usage:#define pipe_progress_trivial_usage NOUSAGE_STR
|
---|
| 20 | //usage:#define pipe_progress_full_usage ""
|
---|
| 21 |
|
---|
[1765] | 22 | #include "libbb.h"
|
---|
[821] | 23 |
|
---|
| 24 | #define PIPE_PROGRESS_SIZE 4096
|
---|
| 25 |
|
---|
| 26 | /* Read a block of data from stdin, write it to stdout.
|
---|
| 27 | * Activity is indicated by a '.' to stderr
|
---|
| 28 | */
|
---|
[2725] | 29 | int pipe_progress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
| 30 | int pipe_progress_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
---|
[821] | 31 | {
|
---|
[2725] | 32 | char buf[PIPE_PROGRESS_SIZE];
|
---|
[821] | 33 | time_t t = time(NULL);
|
---|
[2725] | 34 | int len;
|
---|
[821] | 35 |
|
---|
[2725] | 36 | while ((len = safe_read(STDIN_FILENO, buf, PIPE_PROGRESS_SIZE)) > 0) {
|
---|
[821] | 37 | time_t new_time = time(NULL);
|
---|
| 38 | if (new_time != t) {
|
---|
| 39 | t = new_time;
|
---|
[2725] | 40 | bb_putchar_stderr('.');
|
---|
[821] | 41 | }
|
---|
[2725] | 42 | full_write(STDOUT_FILENO, buf, len);
|
---|
[821] | 43 | }
|
---|
| 44 |
|
---|
[2725] | 45 | bb_putchar_stderr('\n');
|
---|
[821] | 46 |
|
---|
| 47 | return 0;
|
---|
| 48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.