Lines Matching refs:TT

12  * the same field should be called "TT" which is _INSANE_ and I'm not doing it.
306 * We record active columns in TT.bits, ala:
308 * if (TT.bits & _PS_NAME) printf("-o included PS_NAME");
463 {&TT.gg, SLOT_gid}, {&TT.GG, SLOT_rgid}, {&TT.pp, SLOT_pid},
464 {&TT.PP, SLOT_ppid}, {&TT.ss, SLOT_sid}, {&TT.tt, SLOT_ttynr},
465 {&TT.uu, SLOT_uid}, {&TT.UU, SLOT_ruid}
495 if (!(FLAG(a)||FLAG(d)||FLAG(A)||FLAG(e)) && TT.tty!=slot[SLOT_ttynr])
554 int unit = 60, pad = 2, j = TT.ticks;
576 sprintf(s, ".%02lld", (100*(ll%TT.ticks))/TT.ticks);
601 if (TT.forcek) sprintf(out, "%lldk", ll/1024);
620 time_t t = time(0)-slot[SLOT_uptime]+slot[SLOT_starttime]/TT.ticks;
636 // Display process data that get_ps() read from /proc, formatting via TT.fields
641 int pad, len, width = TT.width, abslen, sign, olen, extra = 0;
644 for (field = TT.fields; field; field = field->next) {
651 if (field != TT.fields) {
660 olen = (TT.tty) ? utf8len(out) : strlen(out);
691 if (TT.tty) width -= draw_trim(out, pad, len);
696 putchar(TT.time ? '\r' : '\n');
723 |(DIRTREE_SAVE*(TT.threadparent||!TT.show_process));
728 if (TT.threadparent && TT.threadparent->extra) {
729 struct procpid *tb2 = (struct procpid *)TT.threadparent->extra;
763 if (!TT.tty) tb->str[i] = '?';
781 if ((TT.bits&(_PS_RGROUP|_PS_RUSER|_PS_STAT|_PS_RUID|_PS_RGID|_PS_SWAP
782 |_PS_IO|_PS_DIO)) || TT.GG.len || TT.UU.len)
797 if (TT.bits&(_PS_READ|_PS_WRITE|_PS_DREAD|_PS_DWRITE|_PS_IO|_PS_DIO)) {
814 if (TT.match_process && !TT.match_process(slot)) return 0;
821 slot[SLOT_upticks] = slot[SLOT_uptime]*TT.ticks - slot[SLOT_starttime];
824 if (TT.bits&(_PS_VIRT|_PS_SHR)) {
836 if (TT.bits&_PS_BIT) {
847 if (TT.bits&_PS_PCY)
865 if (!(TT.bits&fetch[j].bits)) {
886 if (TT.threadparent && TT.threadparent->extra)
887 ptb = (void *)TT.threadparent->extra;
969 } else if (!TT.tty && c<' ') c = '?';
984 TT.kcount++;
985 if (TT.show_process && !TT.threadparent) {
986 TT.show_process(tb);
1009 TT.threadparent = new;
1012 TT.threadparent = 0;
1019 kcount = TT.kcount;
1023 TT.threadparent = 0;
1024 kcount = TT.kcount-kcount+1;
1037 if (!TT.show_process) return DIRTREE_SAVE;
1038 TT.show_process((void *)new->extra);
1043 TT.show_process((void *)dt->child->extra);
1154 if (pl==&TT.ss && ll[pl->len]==0) ll[pl->len] = getsid(0);
1157 if (pl==&TT.pp || pl==&TT.ss) {
1163 } else if (pl==&TT.tt) {
1194 if (pl==&TT.gg || pl==&TT.GG) {
1201 } else if (pl==&TT.uu || pl==&TT.UU) {
1222 for (field = TT.kfields; field && !ret; field = field->next) {
1289 TT.ticks = sysconf(_SC_CLK_TCK); // units for starttime/uptime
1294 if (!fstat(i, &st)) TT.tty = st.st_rdev;
1298 TT.width = 80;
1299 if (!isatty(1) || !terminal_size(&TT.width, 0)) toys.optflags |= FLAG_w;
1300 if (FLAG(w)) TT.width = 99999;
1303 comma_args(TT.ps.P, &TT.PP, "bad -P", parse_rest);
1304 comma_args(TT.ps.p, &TT.pp, "bad -p", parse_rest);
1305 comma_args(TT.ps.t, &TT.tt, "bad -t", parse_rest);
1306 comma_args(TT.ps.s, &TT.ss, "bad -s", parse_rest);
1307 comma_args(TT.ps.u, &TT.uu, "bad -u", parse_rest);
1308 comma_args(TT.ps.U, &TT.UU, "bad -U", parse_rest);
1309 comma_args(TT.ps.g, &TT.gg, "bad -g", parse_rest);
1310 comma_args(TT.ps.G, &TT.GG, "bad -G", parse_rest);
1311 comma_args(TT.ps.k, &TT.kfields, "bad -k", parse_ko);
1312 dlist_terminate(TT.kfields);
1316 if (parse_rest(&TT.pp, *arg, strlen(*arg))) error_exit("bad %s", *arg);
1331 // Init TT.fields. This only uses toybuf if TT.ps.o is NULL
1332 if (FLAG(Z)) default_ko("LABEL", &TT.fields, 0, 0);
1333 default_ko(toybuf, &TT.fields, "bad -o", TT.ps.o);
1335 if (TT.ps.O) {
1336 if (TT.fields) TT.fields = ((struct ofields *)TT.fields)->prev;
1337 comma_args(TT.ps.O, &TT.fields, "bad -O", parse_ko);
1338 if (TT.fields) TT.fields = ((struct ofields *)TT.fields)->next;
1340 dlist_terminate(TT.fields);
1346 for (field = TT.fields; field; field = field->next) {
1355 TT.bits = get_headers(TT.fields, toybuf, sizeof(toybuf));
1356 if (!FLAG(M)) printf("%.*s\n", TT.width, toybuf);
1357 if (!(FLAG(k)||FLAG(M))) TT.show_process = show_ps;
1358 TT.match_process = ps_match_process;
1360 (FLAG(T) || (TT.bits&(_PS_TID|_PS_TCNT)))
1364 struct procpid **tbsort = collate(TT.kcount, dt);
1367 for (i = 0; i<TT.kcount; i++) {
1370 for (field = TT.fields; field; field = field->next) {
1378 get_headers(TT.fields, toybuf, sizeof(toybuf));
1379 printf("%.*s\n", TT.width, toybuf);
1382 if (FLAG(k)) qsort(tbsort, TT.kcount, sizeof(void *), (void *)ksort);
1383 for (i = 0; i<TT.kcount; i++) {
1391 free(TT.gg.ptr);
1392 free(TT.GG.ptr);
1393 free(TT.pp.ptr);
1394 free(TT.PP.ptr);
1395 free(TT.ss.ptr);
1396 free(TT.tt.ptr);
1397 free(TT.uu.ptr);
1398 free(TT.UU.ptr);
1399 llist_traverse(TT.fields, free);
1415 for (field = TT.fields; field; field = field->next) {
1416 if ((TT.sortpos = i++)<pos && field->next) continue;
1417 field2 = TT.kfields;
1435 oslot[SLOT_upticks] = (milis*TT.ticks)/1000;
1446 printf("%s%-*.*s%s\r\n", rev?"\033[7m":"", rev?TT.width:0, TT.width, toybuf,
1473 if (!TT.fields) perror_exit("no -o");
1483 TT.bits = get_headers(TT.fields, toybuf, sizeof(toybuf));
1495 (FLAG(H) || (TT.bits&(_PS_TID|_PS_TCNT))) ? get_threads : get_ps);
1497 plnew->tb = collate(plnew->count = TT.kcount, dt);
1498 TT.kcount = 0;
1520 int merge_idx = (FLAG(H) || (TT.bits&(_PS_TID|_PS_TCNT))) ? SLOT_tid : SLOT_pid;
1558 terminal_probesize(&TT.width, &TT.height);
1561 if (TT.top.m) TT.height = TT.top.m+5;
1562 lines = TT.height;
1634 for (field = TT.fields; field; field = field->next) {
1652 get_headers(TT.fields, pos = toybuf, sizeof(toybuf));
1656 if (isspace(was) && !isspace(is) && i++==TT.sortpos && pos!=toybuf)
1658 if (!isspace(was) && isspace(is) && i==TT.sortpos+1) *pos = ']';
1665 printf("\033[%dH\033[J", 1+TT.height-lines);
1678 if (TT.top.n && !--TT.top.n) {
1684 if (timeout<=now) timeout = new.whence+TT.top.d;
1685 if (timeout<=now || timeout>now+TT.top.d) timeout = now+TT.top.d;
1695 i = scan_key_getsize(scratch, timeout-now, &TT.width, &TT.height);
1704 if (i==27) while (0<scan_key_getsize(scratch, 0, &TT.width, &TT.height));
1709 ((struct ofields *)TT.kfields)->reverse *= -1;
1712 if (i == KEY_LEFT) setsort(TT.sortpos-1);
1713 else if (i == KEY_RIGHT) setsort(TT.sortpos+1);
1739 TT.ticks = sysconf(_SC_CLK_TCK); // units for starttime/uptime
1740 TT.tty = tty_fd() != -1;
1743 if (FLAG(b)) TT.width = TT.height = 99999;
1747 TT.time = millitime();
1748 start_redraw(&TT.width, &TT.height);
1751 comma_args(TT.top.u, &TT.uu, "bad -u", parse_rest);
1752 comma_args(TT.top.p, &TT.pp, "bad -p", parse_rest);
1753 TT.match_process = shared_match_process;
1755 default_ko(defo, &TT.fields, "bad -o", TT.top.o);
1756 dlist_terminate(TT.fields);
1759 default_ko("-S", &TT.kfields, 0, 0);
1760 default_ko(defk, &TT.kfields, "bad -k", TT.top.k);
1761 dlist_terminate(TT.kfields);
1762 setsort(TT.top.s-1);
1768 TT.top.O ? "" : "PR,NI,VIRT,RES,SHR,S,",
1770 if (!TT.top.s) TT.top.s = TT.top.O ? 3 : 9;
1772 if (TT.top.O) {
1773 struct ofields *field = TT.fields;
1776 comma_args(TT.top.O, &field, "bad -O", parse_ko);
1791 else oslot[SLOT_upticks] = ((millitime()-TT.time)*TT.ticks)/1000;
1800 if (FLAG(K)) TT.forcek++;
1824 if (TT.pgrep.signal) {
1825 if (kill(*tb->slot, TT.pgrep.signal)) {
1826 char *s = num_to_sig(TT.pgrep.signal);
1828 if (!s) sprintf(s = toybuf, "%d", TT.pgrep.signal);
1832 if (!FLAG(c) && (!TT.pgrep.signal || TT.tty)) {
1837 printf("%s", TT.pgrep.d ? TT.pgrep.d : "\n");
1849 if (TT.pgrep.self == *tb->slot) return;
1851 if (TT.pgrep.regexes) {
1852 for (reg = TT.pgrep.regexes; reg; reg = reg->next) {
1865 TT.sortpos++;
1870 if (TT.time && TT.time>ll) return;
1871 TT.time = ll;
1872 free(TT.pgrep.snapshot);
1873 TT.pgrep.snapshot = xmemdup(toybuf, (name+strlen(name)+1)-toybuf);
1887 TT.pgrep.self = getpid();
1890 if (TT.pgrep.L && 1>(TT.pgrep.signal = sig_to_num(TT.pgrep.L)))
1891 error_exit("bad -L '%s'", TT.pgrep.L);
1893 comma_args(TT.pgrep.G, &TT.GG, "bad -G", parse_rest);
1894 comma_args(TT.pgrep.g, &TT.gg, "bad -g", parse_rest);
1895 comma_args(TT.pgrep.P, &TT.PP, "bad -P", parse_rest);
1896 comma_args(TT.pgrep.s, &TT.ss, "bad -s", parse_rest);
1897 comma_args(TT.pgrep.t, &TT.tt, "bad -t", parse_rest);
1898 comma_args(TT.pgrep.U, &TT.UU, "bad -U", parse_rest);
1899 comma_args(TT.pgrep.u, &TT.uu, "bad -u", parse_rest);
1905 if (FLAG(f)) TT.bits |= _PS_CMDLINE;
1909 reg->next = TT.pgrep.regexes;
1910 TT.pgrep.regexes = reg;
1912 TT.match_process = pgrep_match_process;
1913 TT.show_process = match_pgrep;
1919 if (FLAG(c)) printf("%d\n", TT.sortpos);
1920 if (TT.pgrep.snapshot) {
1921 do_pgk(TT.pgrep.snapshot);
1922 if (CFG_TOYBOX_FREE) free(TT.pgrep.snapshot);
1924 if (TT.pgrep.d) xputc('\n');
1935 if (!FLAG(l) && *args && **args=='-') TT.pgrep.L = *(args++)+1;
1936 if (!TT.pgrep.L) TT.pgrep.signal = SIGTERM;
1937 if (FLAG(V)) TT.tty = 1;