1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
--- progressbar.c.bak/progressbar.c.bak
+++ progressbar.c.bak/progressbar.c
@@ -56,8 +56,8 @@
{
struct winsize winsize;
- if(ioctl(1, TIOCGWINSZ, &winsize) == -1) {
- if(isatty(STDOUT_FILENO))
+ if(ioctl(2, TIOCGWINSZ, &winsize) == -1) {
+ if(isatty(STDERR_FILENO))
ERROR("TIOCGWINSZ ioctl failed, defaulting to 80 "
"columns\n");
columns = 80;
@@ -108,7 +108,7 @@
return;
if(tty == -1)
- tty = isatty(STDOUT_FILENO);
+ tty = isatty(STDERR_FILENO);
if(!tty) {
static long long previous = -1;
@@ -122,19 +122,19 @@
previous = current;
}
- printf("\r[");
+ fprintf(stderr, "\r[");
while (hashes --)
- putchar('=');
+ putc('=', stderr);
- putchar(rotate_list[rotate]);
+ putc(rotate_list[rotate], stderr);
while(spaces --)
- putchar(' ');
+ putc(' ', stderr);
- printf("] %*lld/%*lld", max_digits, current, max_digits, max);
- printf(" %3lld%%", current * 100 / max);
- fflush(stdout);
+ fprintf(stderr, "] %*lld/%*lld", max_digits, current, max_digits, max);
+ fprintf(stderr, " %3lld%%", current * 100 / max);
+ fflush(stderr);
}
@@ -180,8 +180,8 @@
struct itimerval itimerval;
struct winsize winsize;
- if(ioctl(1, TIOCGWINSZ, &winsize) == -1) {
- if(isatty(STDOUT_FILENO))
+ if(ioctl(2, TIOCGWINSZ, &winsize) == -1) {
+ if(isatty(STDERR_FILENO))
ERROR("TIOCGWINSZ ioctl failed, defaulting to 80 "
"columns\n");
columns = 80;
|