top(1): Raise WARNS to 6 and fix warnings.
[dragonfly.git] / contrib / top / top.c
blob424843a23d6bbbf684da7576b2444c43fdea4dc7
1 const char *copyright =
2 "Copyright (c) 1984 through 1996, William LeFebvre";
4 /*
5 * Top users/processes display for Unix
6 * Version 3
8 * This program may be freely redistributed,
9 * but this entire comment MUST remain intact.
11 * Copyright (c) 1984, 1989, William LeFebvre, Rice University
12 * Copyright (c) 1989 - 1994, William LeFebvre, Northwestern University
13 * Copyright (c) 1994, 1995, William LeFebvre, Argonne National Laboratory
14 * Copyright (c) 1996, William LeFebvre, Group sys Consulting
16 * $FreeBSD: src/contrib/top/top.c,v 1.4.6.5 2002/08/11 17:09:25 dwmalone Exp $
17 * $DragonFly: src/contrib/top/top.c,v 1.4 2006/10/03 12:20:11 y0netan1 Exp $
21 * See the file "Changes" for information on version-to-version changes.
25 * This file contains "main" and other high-level routines.
29 * The following preprocessor variables, when defined, are used to
30 * distinguish between different Unix implementations:
32 * SIGHOLD - use SVR4 sighold function when defined
33 * SIGRELSE - use SVR4 sigrelse function when defined
34 * FD_SET - macros FD_SET and FD_ZERO are used when defined
37 #include "os.h"
38 #include <errno.h>
39 #include <time.h>
40 #include <curses.h>
41 #include <unistd.h>
42 #include <signal.h>
43 #include <setjmp.h>
44 #include <ctype.h>
45 #include <sys/time.h>
47 /* includes specific to top */
48 #include "display.h" /* interface to display package */
49 #include "screen.h" /* interface to screen package */
50 #include "top.h"
51 #include "top.local.h"
52 #include "boolean.h"
53 #include "machine.h"
54 #include "username.h"
55 #include "commands.h"
56 #include "utils.h"
58 /* Size of the stdio buffer given to stdout */
59 #define Buffersize 2048
61 /* The buffer that stdio will use */
62 char stdoutbuf[Buffersize];
64 /* build Signal masks */
65 #define Smask(s) (1 << ((s) - 1))
67 /* imported from screen.c */
68 extern int overstrike;
70 /* signal handling routines */
71 sigret_t leave(int signo);
72 sigret_t onalrm(int signo);
73 sigret_t tstop(int signo);
74 #ifdef SIGWINCH
75 sigret_t mywinch(int signo);
76 #endif
78 volatile sig_atomic_t leaveflag;
79 volatile sig_atomic_t tstopflag;
80 volatile sig_atomic_t winchflag;
82 /* values which need to be accessed by signal handlers */
83 static int max_topn; /* maximum displayable processes */
85 static void reset_display(void);
87 /* miscellaneous things */
88 const char *myname = "top";
89 jmp_buf jmp_int;
91 /* pointers to display routines */
92 void (*d_loadave)(int, double *) = i_loadave;
93 void (*d_procstates)(int, int *) = i_procstates;
94 void (*d_cpustates)(struct system_info *) = i_cpustates;
95 void (*d_memory)(int *) = i_memory;
96 void (*d_swap)(int *) = i_swap;
97 void (*d_message)(void) = i_message;
98 void (*d_header)(char *) = i_header;
99 void (*d_process)(int, char *) = i_process;
101 int n_cpus = 0;
104 main(int argc, char **argv)
106 int i;
107 int active_procs;
108 int change;
110 struct system_info system_info;
111 struct statics statics;
112 caddr_t processes;
114 static char tempbuf1[50];
115 static char tempbuf2[50];
116 int old_sigmask; /* only used for BSD-style signals */
117 int topn = Default_TOPN;
118 int delay = Default_DELAY;
119 int displays = 0; /* indicates unspecified */
120 int sel_ret = 0;
121 time_t curr_time;
122 char *(*get_userid)(long) = username;
123 const char *uname_field = "USERNAME";
124 char *header_text;
125 char *env_top;
126 char **preset_argv;
127 int preset_argc = 0;
128 char **av = NULL;
129 int ac = 0;
130 char dostates = No;
131 char do_unames = Yes;
132 char interactive = Maybe;
133 char warnings = 0;
134 #if Default_TOPN == Infinity
135 char topn_specified = No;
136 #endif
137 char ch;
138 char *iptr;
139 char no_command = 1;
140 struct timeval mytimeout;
141 struct process_select ps;
142 #ifdef ORDER
143 char *order_name = NULL;
144 int order_index = 0;
145 #endif
146 #ifndef FD_SET
147 /* FD_SET and friends are not present: fake it */
148 typedef int fd_set;
149 #define FD_ZERO(x) (*(x) = 0)
150 #define FD_SET(f, x) (*(x) = 1<<f)
151 #endif
152 fd_set readfds;
154 #ifdef ORDER
155 static char command_chars[] = "\f qh?en#sdkriIutTOSo";
156 #else
157 static char command_chars[] = "\f qh?en#sdkriIutTOSO";
158 #endif
159 /* these defines enumerate the "strchr"s of the commands in command_chars */
160 #define CMD_redraw 0
161 #define CMD_update 1
162 #define CMD_quit 2
163 #define CMD_help1 3
164 #define CMD_help2 4
165 #define CMD_OSLIMIT 4 /* terminals with OS can only handle commands */
166 #define CMD_errors 5 /* less than or equal to CMD_OSLIMIT */
167 #define CMD_number1 6
168 #define CMD_number2 7
169 #define CMD_delay 8
170 #define CMD_displays 9
171 #define CMD_kill 10
172 #define CMD_renice 11
173 #define CMD_idletog 12
174 #define CMD_idletog2 13
175 #define CMD_user 14
176 #define CMD_selftog 15
177 #define CMD_threads 16
178 #define CMD_othreads 17
179 #define CMD_system 18
180 #ifdef ORDER
181 #define CMD_order 19
182 #endif
184 /* set the buffer for stdout */
185 #ifdef DEBUG
186 extern FILE *debug;
187 debug = fopen("debug.run", "w");
188 setbuffer(stdout, NULL, 0);
189 #else
190 setbuffer(stdout, stdoutbuf, Buffersize);
191 #endif
193 /* get our name */
194 if (argc > 0)
196 if ((myname = strrchr(argv[0], '/')) == 0)
198 myname = argv[0];
200 else
202 myname++;
206 /* initialize some selection options */
207 ps.idle = Yes;
208 ps.self = -1;
209 ps.system = No;
210 ps.threads = No;
211 ps.only_threads = No;
212 ps.uid = -1;
213 ps.command = NULL;
215 /* get preset options from the environment */
216 if ((env_top = getenv("TOP")) != NULL)
218 av = preset_argv = argparse(env_top, &preset_argc);
219 ac = preset_argc;
221 /* set the dummy argument to an explanatory message, in case
222 getopt encounters a bad argument */
223 preset_argv[0] = strdup("while processing environment");
226 /* process options */
227 do {
228 /* if we're done doing the presets, then process the real arguments */
229 if (preset_argc == 0)
231 ac = argc;
232 av = argv;
234 /* this should keep getopt happy... */
235 optind = 1;
238 while ((i = getopt(ac, av, "SITONbinquvs:d:U:o:t")) != EOF)
240 switch(i)
242 case 'v': /* show version number */
243 fprintf(stderr, "%s: version %s\n",
244 myname, version_string());
245 exit(1);
246 break;
248 case 'u': /* toggle uid/username display */
249 do_unames = !do_unames;
250 break;
252 case 'U': /* display only username's processes */
253 if ((ps.uid = userid(optarg)) == -1)
255 fprintf(stderr, "%s: unknown user\n", optarg);
256 exit(1);
258 break;
260 case 'S': /* show system processes */
261 ps.system = !ps.system;
262 break;
264 case 'I': /* show idle processes */
265 ps.idle = !ps.idle;
266 break;
268 case 'O':
269 ps.only_threads = !ps.only_threads; /* only threads */
270 break;
272 case 'T':
273 ps.threads = !ps.threads; /* show threads */
274 break;
276 case 'i': /* go interactive regardless */
277 interactive = Yes;
278 break;
280 case 'n': /* batch, or non-interactive */
281 case 'b':
282 interactive = No;
283 break;
285 case 'd': /* number of displays to show */
286 if ((i = atoiwi(optarg)) == Invalid || i == 0)
288 fprintf(stderr,
289 "%s: warning: display count should be positive -- option ignored\n",
290 myname);
291 warnings++;
293 else
295 displays = i;
297 break;
299 case 's':
300 if ((delay = atoi(optarg)) < 0 || (delay == 0 && getuid() != 0))
302 fprintf(stderr,
303 "%s: warning: seconds delay should be positive -- using default\n",
304 myname);
305 delay = Default_DELAY;
306 warnings++;
308 break;
310 case 'q': /* be quick about it */
311 /* only allow this if user is really root */
312 if (getuid() == 0)
314 /* be very un-nice! */
315 (void) nice(-20);
317 else
319 fprintf(stderr,
320 "%s: warning: `-q' option can only be used by root\n",
321 myname);
322 warnings++;
324 break;
326 case 'o': /* select sort order */
327 #ifdef ORDER
328 order_name = optarg;
329 #else
330 fprintf(stderr,
331 "%s: this platform does not support arbitrary ordering. Sorry.\n",
332 myname);
333 warnings++;
334 #endif
335 break;
337 case 't':
338 ps.self = (ps.self == -1) ? getpid() : -1;
339 break;
341 default:
342 fprintf(stderr, "\
343 Top version %s\n\
344 Usage: %s [-ISbinqut] [-d x] [-s x] [-o field] [-U username] [number]\n",
345 version_string(), myname);
346 exit(1);
350 /* get count of top processes to display (if any) */
351 if (optind < ac)
353 if ((topn = atoiwi(av[optind])) == Invalid)
355 fprintf(stderr,
356 "%s: warning: process display count should be non-negative -- using default\n",
357 myname);
358 warnings++;
360 #if Default_TOPN == Infinity
361 else
363 topn_specified = Yes;
365 #endif
368 /* tricky: remember old value of preset_argc & set preset_argc = 0 */
369 i = preset_argc;
370 preset_argc = 0;
372 /* repeat only if we really did the preset arguments */
373 } while (i != 0);
375 /* set constants for username/uid display correctly */
376 if (!do_unames)
378 uname_field = " UID ";
379 get_userid = ltoa7;
382 /* initialize the kernel memory interface */
383 if (machine_init(&statics) == -1)
385 exit(1);
388 #ifdef ORDER
389 /* determine sorting order index, if necessary */
390 if (order_name != NULL)
392 if ((order_index = string_index(order_name, statics.order_names)) == -1)
394 const char **pp;
396 fprintf(stderr, "%s: '%s' is not a recognized sorting order.\n",
397 myname, order_name);
398 fprintf(stderr, "\tTry one of these:");
399 pp = statics.order_names;
400 while (*pp != NULL)
402 fprintf(stderr, " %s", *pp++);
404 fputc('\n', stderr);
405 exit(1);
408 #endif
410 #ifdef no_initialization_needed
411 /* initialize the hashing stuff */
412 if (do_unames)
414 init_hash();
416 #endif
418 /* initialize termcap */
419 init_termcap(interactive);
421 /* get the string to use for the process area header */
422 header_text = format_header(uname_field);
424 /* initialize display interface */
425 if ((max_topn = display_init(&statics)) == -1)
427 fprintf(stderr, "%s: can't allocate sufficient memory\n", myname);
428 exit(4);
431 /* print warning if user requested more processes than we can display */
432 if (topn > max_topn)
434 fprintf(stderr,
435 "%s: warning: this terminal can only display %d processes.\n",
436 myname, max_topn);
437 warnings++;
440 /* adjust for topn == Infinity */
441 if (topn == Infinity)
444 * For smart terminals, infinity really means everything that can
445 * be displayed, or Largest.
446 * On dumb terminals, infinity means every process in the system!
447 * We only really want to do that if it was explicitly specified.
448 * This is always the case when "Default_TOPN != Infinity". But if
449 * topn wasn't explicitly specified and we are on a dumb terminal
450 * and the default is Infinity, then (and only then) we use
451 * "Nominal_TOPN" instead.
453 #if Default_TOPN == Infinity
454 topn = smart_terminal ? Largest :
455 (topn_specified ? Largest : Nominal_TOPN);
456 #else
457 topn = Largest;
458 #endif
461 /* set header display accordingly */
462 display_header(topn > 0);
464 /* determine interactive state */
465 if (interactive == Maybe)
467 interactive = smart_terminal;
470 /* if # of displays not specified, fill it in */
471 if (displays == 0)
473 displays = smart_terminal ? Infinity : 1;
476 /* hold interrupt signals while setting up the screen and the handlers */
477 #ifdef SIGHOLD
478 sighold(SIGINT);
479 sighold(SIGQUIT);
480 sighold(SIGTSTP);
481 #else
482 old_sigmask = sigblock(Smask(SIGINT) | Smask(SIGQUIT) | Smask(SIGTSTP));
483 #endif
484 init_screen();
485 (void) signal(SIGINT, leave);
486 (void) signal(SIGQUIT, leave);
487 (void) signal(SIGTSTP, tstop);
488 #ifdef SIGWINCH
489 (void) signal(SIGWINCH, mywinch);
490 #endif
491 #ifdef SIGRELSE
492 sigrelse(SIGINT);
493 sigrelse(SIGQUIT);
494 sigrelse(SIGTSTP);
495 #else
496 (void) sigsetmask(old_sigmask);
497 #endif
498 if (warnings)
500 fputs("....", stderr);
501 fflush(stderr); /* why must I do this? */
502 sleep((unsigned)(3 * warnings));
503 fputc('\n', stderr);
506 restart:
509 * main loop -- repeat while display count is positive or while it
510 * indicates infinity (by being -1)
513 while ((displays == -1) || (displays-- > 0))
515 /* get the current stats */
516 get_system_info(&system_info);
518 /* get the current set of processes */
519 processes =
520 get_process_info(&system_info,
521 &ps,
522 #ifdef ORDER
523 proc_compares[order_index]);
524 #else
525 proc_compare);
526 #endif
528 /* display the load averages */
529 (*d_loadave)(system_info.last_pid,
530 system_info.load_avg);
532 /* display the current time */
533 /* this method of getting the time SHOULD be fairly portable */
534 time(&curr_time);
535 i_uptime(&system_info.boottime, &curr_time);
536 i_timeofday(&curr_time);
538 /* display process state breakdown */
539 (*d_procstates)(system_info.p_total,
540 system_info.procstates);
542 /* display the cpu state percentage breakdown */
543 if (dostates) /* but not the first time */
545 (*d_cpustates)(&system_info);
547 else
549 /* we'll do it next time */
550 if (smart_terminal)
552 z_cpustates(&system_info);
554 else
556 putchar('\n');
558 dostates = Yes;
561 /* display memory stats */
562 (*d_memory)(system_info.memory);
564 /* display swap stats */
565 (*d_swap)(system_info.swap);
567 /* handle message area */
568 (*d_message)();
570 /* update the header area */
571 (*d_header)(header_text);
573 if (topn > 0)
575 /* determine number of processes to actually display */
576 /* this number will be the smallest of: active processes,
577 number user requested, number current screen accomodates */
578 active_procs = system_info.P_ACTIVE;
579 if (active_procs > topn)
581 active_procs = topn;
583 if (active_procs > max_topn)
585 active_procs = max_topn;
588 /* now show the top "n" processes. */
589 for (i = 0; i < active_procs; i++)
591 (*d_process)(i, format_next_process(processes, get_userid));
594 else
596 i = 0;
599 /* do end-screen processing */
600 u_endscreen(i);
602 /* now, flush the output buffer */
603 if (fflush(stdout) != 0)
605 new_message(MT_standout, " Write error on stdout");
606 putchar('\r');
607 quit(1);
608 /*NOTREACHED*/
611 /* only do the rest if we have more displays to show */
612 if (displays)
614 /* switch out for new display on smart terminals */
615 if (smart_terminal)
617 if (overstrike)
619 reset_display();
621 else
623 d_loadave = u_loadave;
624 d_procstates = u_procstates;
625 d_cpustates = i_cpustates;
626 d_memory = u_memory;
627 d_swap = u_swap;
628 d_message = u_message;
629 d_header = u_header;
630 d_process = u_process;
634 no_command = Yes;
635 if (!interactive)
637 /* set up alarm */
638 (void) signal(SIGALRM, onalrm);
639 (void) alarm((unsigned)delay);
641 /* wait for the rest of it .... */
642 pause();
644 else while (no_command)
646 /* assume valid command unless told otherwise */
647 no_command = No;
649 /* set up arguments for select with timeout */
650 FD_ZERO(&readfds);
651 FD_SET(0, &readfds); /* for standard input */
652 mytimeout.tv_sec = delay;
653 mytimeout.tv_usec = 0;
655 if (leaveflag) {
656 end_screen();
657 exit(0);
660 if (tstopflag) {
661 /* move to the lower left */
662 end_screen();
663 fflush(stdout);
665 /* default the signal handler action */
666 (void) signal(SIGTSTP, SIG_DFL);
668 /* unblock the signal and send ourselves one */
669 #ifdef SIGRELSE
670 sigrelse(SIGTSTP);
671 #else
672 (void) sigsetmask(sigblock(0) & ~(1 << (SIGTSTP - 1)));
673 #endif
674 (void) kill(0, SIGTSTP);
676 /* reset the signal handler */
677 (void) signal(SIGTSTP, tstop);
679 /* reinit screen */
680 reinit_screen();
681 reset_display();
682 tstopflag = 0;
683 goto restart;
686 if (winchflag) {
687 /* reascertain the screen dimensions */
688 get_screensize();
690 /* tell display to resize */
691 max_topn = display_resize();
693 /* reset the signal handler */
694 (void) signal(SIGWINCH, mywinch);
696 reset_display();
697 winchflag = 0;
698 goto restart;
701 /* wait for either input or the end of the delay period */
702 sel_ret = select(2, &readfds, NULL, NULL, &mytimeout);
703 if (sel_ret < 0 && errno != EINTR)
704 quit(0);
705 if (sel_ret > 0)
707 int newval;
708 const char *xerrmsg;
710 /* something to read -- clear the message area first */
711 clear_message();
713 /* now read it and convert to command strchr */
714 /* (use "change" as a temporary to hold strchr) */
715 if (read(0, &ch, 1) != 1)
717 /* read error: either 0 or -1 */
718 new_message(MT_standout, " Read error on stdin");
719 putchar('\r');
720 quit(1);
721 /*NOTREACHED*/
723 if ((iptr = strchr(command_chars, ch)) == NULL)
725 if (ch != '\r' && ch != '\n')
727 /* illegal command */
728 new_message(MT_standout, " Command not understood");
730 putchar('\r');
731 no_command = Yes;
733 else
735 change = iptr - command_chars;
736 if (overstrike && change > CMD_OSLIMIT)
738 /* error */
739 new_message(MT_standout,
740 " Command cannot be handled by this terminal");
741 putchar('\r');
742 no_command = Yes;
744 else switch(change)
746 case CMD_redraw: /* redraw screen */
747 reset_display();
748 break;
750 case CMD_update: /* merely update display */
751 /* is the load average high? */
752 if (system_info.load_avg[0] > LoadMax)
754 /* yes, go home for visual feedback */
755 go_home();
756 fflush(stdout);
758 break;
760 case CMD_quit: /* quit */
761 quit(0);
762 /*NOTREACHED*/
763 break;
765 case CMD_help1: /* help */
766 case CMD_help2:
767 reset_display();
768 clear_myscreen();
769 show_help();
770 dostandout("Hit any key to continue: ");
771 fflush(stdout);
772 (void) read(0, &ch, 1);
773 break;
775 case CMD_errors: /* show errors */
776 if (error_count() == 0)
778 new_message(MT_standout,
779 " Currently no errors to report.");
780 putchar('\r');
781 no_command = Yes;
783 else
785 reset_display();
786 clear_myscreen();
787 show_errors();
788 dostandout("Hit any key to continue: ");
789 fflush(stdout);
790 (void) read(0, &ch, 1);
792 break;
794 case CMD_number1: /* new number */
795 case CMD_number2:
796 new_message(MT_standout,
797 "Number of processes to show: ");
798 newval = readline(tempbuf1, 8, Yes);
799 if (newval > -1)
801 if (newval > max_topn)
803 new_message(MT_standout | MT_delayed,
804 " This terminal can only display %d processes.",
805 max_topn);
806 putchar('\r');
809 if (newval == 0)
811 /* inhibit the header */
812 display_header(No);
814 else if (newval > topn && topn == 0)
816 /* redraw the header */
817 display_header(Yes);
818 d_header = i_header;
820 topn = newval;
822 break;
824 case CMD_delay: /* new seconds delay */
825 new_message(MT_standout, "Seconds to delay: ");
826 if ((i = readline(tempbuf1, 8, Yes)) > -1)
828 if ((delay = i) == 0 && getuid() != 0)
830 delay = 1;
833 clear_message();
834 break;
836 case CMD_displays: /* change display count */
837 new_message(MT_standout,
838 "Displays to show (currently %s): ",
839 displays == -1 ? "infinite" :
840 ltoa(displays));
841 if ((i = readline(tempbuf1, 10, Yes)) > 0)
843 displays = i;
845 else if (i == 0)
847 quit(0);
849 clear_message();
850 break;
852 case CMD_kill: /* kill program */
853 new_message(0, "kill ");
854 if (readline(tempbuf2, sizeof(tempbuf2), No) > 0)
856 if ((xerrmsg = kill_procs(tempbuf2)) != NULL)
858 new_message(MT_standout, "%s", xerrmsg);
859 putchar('\r');
860 no_command = Yes;
863 else
865 clear_message();
867 break;
869 case CMD_renice: /* renice program */
870 new_message(0, "renice ");
871 if (readline(tempbuf2, sizeof(tempbuf2), No) > 0)
873 if ((xerrmsg = renice_procs(tempbuf2)) != NULL)
875 new_message(MT_standout, "%s", xerrmsg);
876 putchar('\r');
877 no_command = Yes;
880 else
882 clear_message();
884 break;
886 case CMD_idletog:
887 case CMD_idletog2:
888 ps.idle = !ps.idle;
889 new_message(MT_standout | MT_delayed,
890 " %sisplaying idle processes.",
891 ps.idle ? "D" : "Not d");
892 putchar('\r');
893 break;
895 case CMD_selftog:
896 ps.self = (ps.self == -1) ? getpid() : -1;
897 new_message(MT_standout | MT_delayed,
898 " %sisplaying self.",
899 (ps.self == -1) ? "D" : "Not d");
900 putchar('\r');
901 break;
903 case CMD_threads:
904 ps.threads = !ps.threads;
905 new_message(MT_standout | MT_delayed,
906 " %sisplaying threads.",
907 ps.threads ? "D" : "Not d");
908 putchar('\r');
909 break;
911 case CMD_othreads:
912 ps.only_threads = !ps.only_threads;
913 new_message(MT_standout | MT_delayed,
914 ps.only_threads ?
915 "Only displaying threads." :
916 "Displaying threads and processes.");
917 putchar('\r');
918 break;
920 case CMD_system:
921 ps.system = !ps.system;
922 new_message(MT_standout | MT_delayed,
923 " %sisplaying system processes.",
924 ps.system ? "D" : "Not d");
925 putchar('\r');
926 break;
928 case CMD_user:
929 new_message(MT_standout,
930 "Username to show: ");
931 if (readline(tempbuf2, sizeof(tempbuf2), No) > 0)
933 if (tempbuf2[0] == '+' &&
934 tempbuf2[1] == '\0')
936 ps.uid = -1;
938 else if ((i = userid(tempbuf2)) == -1)
940 new_message(MT_standout,
941 " %s: unknown user", tempbuf2);
942 no_command = Yes;
944 else
946 ps.uid = i;
948 putchar('\r');
950 else
952 clear_message();
954 break;
956 #ifdef ORDER
957 case CMD_order:
958 new_message(MT_standout,
959 "Order to sort: ");
960 if (readline(tempbuf2, sizeof(tempbuf2), No) > 0)
962 if ((i = string_index(tempbuf2, statics.order_names)) == -1)
964 new_message(MT_standout,
965 " %s: unrecognized sorting order", tempbuf2);
966 no_command = Yes;
968 else
970 order_index = i;
972 putchar('\r');
974 else
976 clear_message();
978 break;
979 #endif
981 default:
982 new_message(MT_standout, " BAD CASE IN SWITCH!");
983 putchar('\r');
987 /* flush out stuff that may have been written */
988 fflush(stdout);
994 #ifdef DEBUG
995 fclose(debug);
996 #endif
997 quit(0);
998 /*NOTREACHED*/
999 return(0);
1003 * reset_display() - reset all the display routine pointers so that entire
1004 * screen will get redrawn.
1007 static void
1008 reset_display(void)
1010 d_loadave = i_loadave;
1011 d_procstates = i_procstates;
1012 d_cpustates = i_cpustates;
1013 d_memory = i_memory;
1014 d_swap = i_swap;
1015 d_message = i_message;
1016 d_header = i_header;
1017 d_process = i_process;
1021 * signal handlers
1024 /* exit under normal conditions -- INT handler */
1025 sigret_t
1026 leave(int signo __unused)
1028 leaveflag = 1;
1031 sigret_t
1032 tstop(int signo __unused) /* SIGTSTP handler */
1034 tstopflag = 1;
1037 #ifdef SIGWINCH
1038 sigret_t
1039 mywinch(int signo __unused) /* SIGWINCH handler */
1041 winchflag = 1;
1043 #endif
1045 void
1046 quit(int status) /* exit under duress */
1048 end_screen();
1049 exit(status);
1050 /*NOTREACHED*/
1053 sigret_t
1054 onalrm(int signo __unused) /* SIGALRM handler */
1057 /* this is only used in batch mode to break out of the pause() */
1058 /* return; */