void start_progress_meter(char *f, off_t filesize, off_t *ctr) { struct winsize winsize; start = last_update = time(NULL); file = f; end_pos = filesize; cur_pos = 0; counter = ctr; stalled = 0; bytes_per_second = 0; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) != -1 && winsize.ws_col != 0) { if (winsize.ws_col > MAX_WINSIZE) win_size = MAX_WINSIZE; else win_size = winsize.ws_col; } else win_size = DEFAULT_WINSIZE; win_size += 1; /* trailing \0 */ if (can_output()) refresh_progress_meter(); signal(SIGALRM, update_progress_meter); alarm(UPDATE_INTERVAL); }
void stop_progress_meter(void) { alarm(0); if (!can_output()) return; /* Ensure we complete the progress */ if (cur_pos != end_pos) refresh_progress_meter(); write(STDOUT_FILENO, "\n", 1); }
static void update_progress_meter(int ignore) { int save_errno; save_errno = errno; if (can_output()) refresh_progress_meter(); signal(SIGALRM, update_progress_meter); alarm(UPDATE_INTERVAL); errno = save_errno; }
void stop_progress_meter(void) { alarm(0); if (!can_output()) return; /* Ensure we complete the progress */ if (cur_pos != end_pos) refresh_progress_meter(); /* Silly workaround for -Werror=unused-result */ if (write(STDOUT_FILENO, "\n", 1) <= 0) {} }
/*ARGSUSED*/ static void update_progress_meter(__unused int ignore) { int save_errno; save_errno = errno; if (win_resized) { setscreensize(); win_resized = 0; } if (can_output()) refresh_progress_meter(); signal(SIGALRM, update_progress_meter); alarm(UPDATE_INTERVAL); errno = save_errno; }
void start_progress_meter(char *f, off_t filesize, off_t *ctr) { start = last_update = time(NULL); file = f; end_pos = filesize; cur_pos = 0; counter = ctr; stalled = 0; bytes_per_second = 0; setscreensize(); if (can_output()) refresh_progress_meter(); signal(SIGALRM, update_progress_meter); signal(SIGWINCH, sig_winch); alarm(UPDATE_INTERVAL); }