MCPcopy Index your code
hub / github.com/F-Stack/f-stack / sidewaysintpr

Function sidewaysintpr

tools/netstat/if.c:573–675  ·  view source on GitHub ↗

* Print a running summary of interface statistics. * Repeat display every interval seconds, showing statistics * collected over that interval. Assumes that interval is non-zero. * First line printed at top of screen is always cumulative. */

Source from the content-addressed store, hash-verified

571 * First line printed at top of screen is always cumulative.
572 */
573static void
574sidewaysintpr(void)
575{
576 struct iftot ift[2], *new, *old;
577 struct itimerval interval_it;
578#ifndef FSTACK
579 int oldmask, line;
580#else
581 int line;
582 sigset_t oldmask;
583#endif
584
585 new = &ift[0];
586 old = &ift[1];
587 fill_iftot(old);
588
589 (void)signal(SIGALRM, catchalarm);
590 signalled = false;
591 interval_it.it_interval.tv_sec = interval;
592 interval_it.it_interval.tv_usec = 0;
593 interval_it.it_value = interval_it.it_interval;
594 setitimer(ITIMER_REAL, &interval_it, NULL);
595 xo_open_list("interface-statistics");
596
597banner:
598 xo_emit("{T:/%17s} {T:/%14s} {T:/%16s}\n", "input",
599 interface != NULL ? interface : "(Total)", "output");
600 xo_emit("{T:/%10s} {T:/%5s} {T:/%5s} {T:/%10s} {T:/%10s} {T:/%5s} "
601 "{T:/%10s} {T:/%5s}",
602 "packets", "errs", "idrops", "bytes", "packets", "errs", "bytes",
603 "colls");
604 if (dflag)
605 xo_emit(" {T:/%5.5s}", "drops");
606 xo_emit("\n");
607 xo_flush();
608 line = 0;
609
610loop:
611 if ((noutputs != 0) && (--noutputs == 0)) {
612 xo_close_list("interface-statistics");
613 return;
614 }
615#ifndef FSTACK
616 oldmask = sigblock(sigmask(SIGALRM));
617 while (!signalled)
618 sigpause(0);
619 signalled = false;
620 sigsetmask(oldmask);
621#else
622 sigset_t set;
623 sigemptyset(&set);
624 sigaddset(&set, SIGALRM);
625 sigprocmask(SIG_BLOCK, &set, &oldmask);
626 sigemptyset(&set);
627
628 while (!signalled)
629 sigsuspend(&set);
630 signalled = false;

Callers 1

intprFunction · 0.85

Calls 8

fill_iftotFunction · 0.85
xo_open_listFunction · 0.85
xo_emitFunction · 0.85
xo_flushFunction · 0.85
xo_close_listFunction · 0.85
xo_open_instanceFunction · 0.85
show_statFunction · 0.85
xo_close_instanceFunction · 0.85

Tested by

no test coverage detected