From: Harald Koenig <koenig@tat.physik.uni-tuebingen.de>
Subject: more procps-0.99a fixes...
Date: Sat, 27 Apr 1996 12:17:31 +0200 (MET DST) [thread overview]
Message-ID: <9604271557.AA11263@nova.tat.physik.uni-tuebingen.de> (raw)
two more fixes:
top uses tgetstr() to get some entries from terminfo which are printed
using printf(). those strings may include delays (using $<...>)
which is the case e.g. for the "vt100" terminfo entry.
those delay specificatins are displayed as plain text when using printf()
instead of tputs() or putp(). for vt100 terminals "$<3>" is displayed
at the end of every line (from the top_clrtoeol string) etc.
see fix below.
ps.c has the value of HZ hard coded two times as 100, but for alpha
HZ is 1000...
Harald
-------------------------------------------------------------------------------
--- procps-0.99a/top.c~ Sat Apr 20 17:40:53 1996
+++ procps-0.99a/top.c Sat Apr 27 12:07:02 1996
@@ -119,11 +119,12 @@
/* Clear the screen. */
#define clear_screen() \
- printf("%s", cl)
+ putp(cl)
/* Show an error in the context of the spiffy full-screen display. */
#define SHOWMESSAGE(x) do { \
- printf("%s%s", tgoto(cm, 0, 5), top_clrtoeol); \
+ putp(tgoto(cm, 0, 5)); \
+ putp(top_clrtoeol); \
printf x; \
fflush(stdout); \
sleep(2); \
@@ -290,7 +291,8 @@
end(void)
{
ioctl(0, TCSETAF, &Savetty);
- printf("%s\r\n", tgoto(cm, 0, Lines - 1));
+ putp(tgoto(cm, 0, Lines - 1));
+ printf("\r\n");
_exit(0);
}
@@ -303,7 +305,7 @@
{
/* Reset terminal. */
ioctl(0, TCSETAF, &Savetty);
- printf("%s", tgoto(cm, 0, Lines - 3));
+ putp(tgoto(cm, 0, Lines - 3));
fflush(stdout);
raise(SIGTSTP);
/* Later... */
@@ -439,7 +441,10 @@
unsigned int main_mem;
/* Display the load averages. */
- printf("%s%s%s\n", ho, sprint_uptime(), top_clrtoeol);
+ putp(ho);
+ printf("%s", sprint_uptime());
+ putp(top_clrtoeol);
+ printf("\n");
/* Get the process info. */
ph = refresh_snapshot(ph, 1, 1, 1, 1, 0, 0, 0);
@@ -451,7 +456,8 @@
/* Display the memory and swap space usage. */
main_mem = show_meminfo();
- printf("%s%s", HEADER, top_clrtoeol);
+ printf("%s", HEADER);
+ putp(top_clrtoeol);
/*
* Finally! Loop through to find the top task, and display it.
@@ -511,13 +517,15 @@
cmdptr = best->cmd;
if (strlen(cmdptr) > Maxcmd)
cmdptr[Maxcmd - 1] = 0;
- printf("%s%s", cmdptr, top_clrtoeol);
+ printf("%s", cmdptr);
+ putp(top_clrtoeol);
}
}
New_save_hist[best_index].pcpu = -1;
}
- printf("%s%s", top_clrtobot, tgoto(cm, 0, 5));
+ putp(top_clrtobot);
+ putp(tgoto(cm, 0, 5));
fflush(stdout);
}
@@ -560,20 +568,23 @@
fprintf( stderr, "Cannot get size of memory from /proc/meminfo\n" );
exit(1);
}
- printf("Mem: %5dK av, %5dK used, %5dK free, %5dK shrd, %5dK buff%s\n",
+ printf("Mem: %5dK av, %5dK used, %5dK free, %5dK shrd, %5dK buff",
mem[meminfo_main][meminfo_total] >> 10,
mem[meminfo_main][meminfo_used] >> 10,
mem[meminfo_main][meminfo_free] >> 10,
mem[meminfo_main][meminfo_shared] >> 10,
- mem[meminfo_main][meminfo_buffers] >> 10,
- top_clrtoeol);
- printf("Swap: %5dK av, %5dK used, %5dK free %5dK cached"
- "%s\n%s\n",
+ mem[meminfo_main][meminfo_buffers] >> 10);
+ putp(top_clrtoeol);
+ putchar('\n');
+ printf("Swap: %5dK av, %5dK used, %5dK free %5dK cached",
mem[meminfo_swap][meminfo_total] >> 10,
mem[meminfo_swap][meminfo_used] >> 10,
mem[meminfo_swap][meminfo_free] >> 10,
- mem[meminfo_total][meminfo_cached] >> 10,
- top_clrtoeol, top_clrtoeol);
+ mem[meminfo_total][meminfo_cached] >> 10);
+ putp(top_clrtoeol);
+ putchar('\n');
+ putp(top_clrtoeol);
+ putchar('\n');
return mem[meminfo_main][meminfo_total];
}
@@ -674,14 +685,18 @@
if (pass>0) {
printf("%d processes: %d sleeping, %d running, %d zombie, "
- "%d stopped%s\n",
- ph->count, sleeping, running, zombie, stopped, top_clrtoeol);
+ "%d stopped",
+ ph->count, sleeping, running, zombie, stopped);
+ putp(top_clrtoeol);
+ putchar('\n');
printf("CPU states: %2d.%d%% user, %2d.%d%% system,"
- " %2d.%d%% nice, %2d.%d%% idle%s\n",
+ " %2d.%d%% nice, %2d.%d%% idle",
user_ticks / 10, user_ticks % 10,
system_ticks / 10, system_ticks % 10,
nice_ticks / 10, nice_ticks % 10,
- idle_ticks / 10, idle_ticks % 10, top_clrtoeol);
+ idle_ticks / 10, idle_ticks % 10);
+ putp(top_clrtoeol);
+ putchar('\n');
}
/* Save this frame's information. */
@@ -723,7 +738,9 @@
switch (c) {
case 'h':
- printf("%s%s\nProc-Top Revision 0\n", cl, ho);
+ putp(cl);
+ putp(ho);
+ printf("\nProc-Top Revision 0\n");
printf("%s\n", procps_version);
printf("Secure mode %s; cumulative mode %s; noidle mode %s\n\n",
Secure ? "on" : "off", Cumulative ? "on" : "off",
@@ -747,8 +764,9 @@
pid = getint();
if (pid == -1)
break;
- printf("%s%sKill PID %d with signal [15]: ",
- tgoto(cm, 0, 5), top_clrtoeol, pid);
+ putp(tgoto(cm, 0, 5));
+ putp(top_clrtoeol);
+ printf("Kill PID %d with signal [15]: ", pid);
signal = getsig();
if (signal == -1)
signal = SIGTERM;
@@ -776,8 +794,9 @@
pid = getint();
if (pid == -1)
break;
- printf("%s%sRenice PID %d to value: ",
- tgoto(cm, 0, 5), top_clrtoeol, pid);
+ putp(tgoto(cm, 0, 5));
+ putp(top_clrtoeol);
+ printf("Renice PID %d to value: ", pid);
val = getint();
if (val == -1)
val = 10;
--- procps-0.99a/ps.c~ Sat Feb 24 21:50:04 1996
+++ procps-0.99a/ps.c Sat Apr 27 11:13:35 1996
@@ -402,7 +402,7 @@
s += sprintf(s, "%5d ", p->uid);
else
s += sprintf(s, "%-8s ", p->user);
- seconds = (((GL_current_time * 100) - p->start_time) / HZ);
+ seconds = (((GL_current_time * HZ) - p->start_time) / HZ);
start = GL_time_now - seconds;
total_time = (p->utime + p->stime +
(CL_Sum ? p->cutime + p->cstime : 0));
@@ -464,7 +464,7 @@
sprintf(s, "%2d %5d %8x %8x %8x %s %s %s %3s ",
p->start_code >> 26, p->pid, p->start_stack,
p->kstk_esp, p->kstk_eip,
- prtime(time1, p->timeout, GL_current_time * 100),
+ prtime(time1, p->timeout, GL_current_time * HZ),
prtime(time2, p->it_real_value, 0),
status2(p), p->ttyc);
}
--
All SCSI disks will from now on ___ _____
be required to send an email notice 0--,| /OOOOOOO\
24 hours prior to complete hardware failure! <_/ / /OOOOOOOOOOO\
\ \/OOOOOOOOOOOOOOO\
\ OOOOOOOOOOOOOOOOO|//
Harald Koenig, \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik // / \\ \
koenig@tat.physik.uni-tuebingen.de ^^^^^ ^^^^^
next reply other threads:[~1996-04-27 10:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-04-27 10:17 Harald Koenig [this message]
-- strict thread matches above, loose matches on Subject: below --
1996-04-27 10:17 more procps-0.99a fixes Harald Koenig
1996-04-27 15:59 Harald Koenig
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox