Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/nathanw_sa]: src/usr.bin/top bring in fixes from beta12:



details:   https://anonhg.NetBSD.org/src/rev/dac7836c64c5
branches:  nathanw_sa
changeset: 504680:dac7836c64c5
user:      christos <christos%NetBSD.org@localhost>
date:      Tue May 22 15:38:23 2001 +0000

description:
bring in fixes from beta12:
        - better error checking for read/write failures
        - new install/configure/Makefile and support scripts (we don't use)
        - don't allow 0 delay for non-root accounts
XXX: Someone needs to coordinate to feed back our prototype fixes to Jeff!

diffstat:

 usr.bin/top/Configure    |  565 +++++++++++++++++++++++++++++++++++++++++++++++
 usr.bin/top/Makefile.X   |  117 +++++++++
 usr.bin/top/getans       |  118 +++++++++
 usr.bin/top/patchlevel.h |    4 +
 4 files changed, 804 insertions(+), 0 deletions(-)

diffs (truncated from 820 to 300 lines):

diff -r b3342c50513d -r dac7836c64c5 usr.bin/top/Configure
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/top/Configure     Tue May 22 15:38:23 2001 +0000
@@ -0,0 +1,565 @@
+#!/bin/csh -f
+#
+# Configuration script for top.
+#
+# Use with version 3.0 and higher.
+#
+set PRIME = "/usr/games/primes"
+set vars = (module LoadMax topn NominalTopn delay owner group mode random \
+       TableSize bindir mandir manext mansty \
+       Cmdshell Cmdcc Cmdawk Cmdinstall cdefs)
+set fastrack = 0
+set yesno = (no yes)
+
+onintr byebye
+
+# make sure that getans is there and ready
+if (! -e getans) then
+   echo 'This package is not complete.  The shell file "getans" is missing.'
+   exit 10
+endif
+chmod +x getans
+
+if ($#argv > 0) then
+# fast track configuration
+   set fastrack = 1
+else
+cat <<'EOF'
+Configuration for top, version 3.5
+
+One moment....
+'EOF'
+endif
+
+# collect file names and module names
+ls machine/m_*.c >$$.f
+ls machine/m_*.man >$$.m
+sed -e 's@^machine/m_@@' -e 's/.c$//' $$.f >$$.n
+
+# build Make.desc
+sed -e 's@\.c@.desc\\@' $$.f | sed -e '$s/\\//' >$$.a
+sed -e "/^DESCS/r $$.a" Make.desc.X >Make.desc
+
+# build desc files and SYNOPSIS as needed
+make -f Make.desc >/dev/null
+if ($status != 0) then
+   echo "Unable to build the synopsis."
+   echo 'Make sure the command "make" is on your path and try'
+   echo 'running Configure again.'
+   exit 1
+endif
+
+if (-e .defaults) then
+   echo ""
+   echo "Reading configuration from last time..."
+   source .defaults
+   set nodefaults = 0
+   if ($fastrack == 1) then
+      set module = $1
+   endif
+else
+   if ($fastrack == 1) then
+      echo "No previous configuration was found."
+      set fastrack = 0
+      set module = $1
+   else
+      set module = ""
+   endif
+   set LoadMax     = 5.0
+   set topn        = 15
+   set NominalTopn = 18
+   set delay       = 5
+   set TableSize   = 0
+   set bindir      = /usr/local/bin
+   set mandir      = /usr/man/manl
+   set manext      = l
+   set mansty      = man
+   set nodefaults  = 1
+   set Cmdshell    = /bin/sh
+   set Cmdawk      = awk
+   set Cmdinstall  = ./install
+   set Cmdcc       = cc
+   set cdefs       = -O
+endif
+echo ""
+
+if ($fastrack == 1) then
+   grep -s $module $$.n >/dev/null
+   if ($status != 0) then
+      echo "$module is not recognized.  To see a list of available modules"
+      echo 'run "Configure" with no arguments.'
+      rm -f $$.[fmna]
+      exit 1
+   endif
+   set random1 = `expr $random + 1`
+   cat <<EOF
+Using these settings:
+        Bourne Shell   $Cmdshell
+          C compiler   $Cmdcc
+    Compiler options   $cdefs
+         Awk command   $Cmdawk
+     Install command   $Cmdinstall
+
+              Module   $module
+             LoadMax   $LoadMax
+        Default TOPN   $topn
+        Nominal TOPN   $NominalTopn
+       Default Delay   $delay
+Random passwd access   $yesno[$random1]
+          Table Size   $TableSize
+               Owner   $owner
+         Group Owner   $group
+                Mode   $mode
+       bin directory   $bindir
+       man directory   $mandir
+       man extension   $manext
+       man style       $mansty
+
+EOF
+   goto fast
+endif
+
+cat <<'EOF'
+You will be asked a series of questions.  Each question will have a
+default answer enclosed in brackets, such as "[5.0]".  In most cases,
+the default answer will work well.  To use that value, merely press
+return.
+
+'EOF'
+
+# display synopses
+
+getmod:
+cat <<'EOF'
+
+The following machine-dependent modules are available:
+'EOF'
+awk -F: ' { printf "%-10s %s\n", $1, $2 }' SYNOPSIS
+echo ''
+./getans "What module is appropriate for this machine? " string "$module" .$$
+set module = `cat .$$`
+
+if ("$module" == "") then
+    echo "Please specify a valid module name."
+    goto getmod
+endif
+
+# is it a valid one?
+grep -s "$module" $$.n >/dev/null
+if ($status != 0) then
+    echo "That is not a recognized module name."
+    goto getmod
+endif
+
+# display a full description
+sed -e '1,/DESCRIPTION:/d' -e '/^$/,$d' machine/m_${module}.desc
+
+# verify it
+echo ""
+./getans "Is this what you want to use?" yesno 1 .$$
+if (`cat .$$` == 0) then
+   goto getmod
+endif
+endif
+
+cat <<'EOF'
+
+First we need to find out a little bit about the executables needed to
+compile top.
+
+'EOF'
+./getans "What is the full path name for the Bourne shell" file "$Cmdshell" .$$
+set Cmdshell = `cat .$$`
+
+cat <<'EOF'
+
+Please supply the name of the appropriate command.  It need not be a
+full path name, but the named command does need to exist somewhere on
+the current path.
+
+'EOF'
+./getans "AWK Interpreter" path "$Cmdawk" .$$
+set Cmdawk = `cat .$$`
+./getans "C Compiler" path "$Cmdcc" .$$
+set Cmdcc = `cat .$$`
+
+cat <<'EOF'
+
+The installer command needs to understand Berkeley-esque arguments:
+"-o" for owner, "-g" for group, and "-m" for mode.  A shell script
+called "install" is distributed with top and is suitable for use by
+top.  You can specify a different program here if you like, or use
+the shell script (the default).
+
+'EOF'
+./getans "Installer" path "$Cmdinstall" .$$
+set Cmdinstall = `cat .$$`
+
+cat <<EOF
+
+What other options should be used with the $Cmdcc command (use "none" to
+specify no options)?
+EOF
+./getans "Compiler options" string "$cdefs" .$$
+set cdefs = `cat .$$`
+if ("$cdefs" == "none") then
+    set cdefs = ""
+endif
+
+cat <<'EOF'
+
+Now you need to answer some questions concerning the configuration of
+top itself.
+
+The space command forces an immediate update.  Sometimes, on loaded
+systems, this update will take a significant period of time (because all
+the output is buffered).  So, if the short-term load average is above
+"LoadMax", then top will put the cursor home immediately after the space
+is pressed before the next update is attempted.  This serves as a visual
+acknowledgement of the command.  "LoadMax" should always be specified as a
+floating point number.
+
+'EOF'
+./getans "LoadMax" number "$LoadMax" .$$
+set LoadMax = `cat .$$`
+
+cat <<'EOF'
+
+"Default TOPN" is the default number of processes to show.  This is the
+number that will be used when the user does not specify the number of
+processes to show.  If you want "all" (or infinity) as the default, use
+the value "-1".
+
+'EOF'
+
+./getans "Default TOPN" neginteger "$topn" .$$
+set topn = `cat .$$`
+
+cat <<'EOF'
+
+"Nominal_TOPN" is used as the default TOPN when Default_TOPN is Infinity
+and the output is a dumb terminal.  If we didn't do this, then
+installations who use a default TOPN of Infinity will get every process in
+the system when running top on a dumb terminal (or redirected to a file).
+Note that Nominal_TOPN is a default: it can still be overridden on the
+command line, even with the value "infinity".
+
+'EOF'
+
+./getans "Nominal TOPN" integer "$NominalTopn" .$$
+set NominalTopn = `cat .$$`
+
+cat <<'EOF'
+
+Default Delay is the default number of seconds to wait between screen
+updates.
+
+'EOF'
+
+./getans "Default Delay" integer "$delay" .$$
+set delay = `cat .$$`
+
+echo ""
+
+set rand = 0
+if (-e /etc/nsswitch.conf) then
+   set rand = `grep '^passwd:.*nis' /etc/nsswitch.conf | wc -l`
+   if ($rand > 1) then
+      set rand = 1
+   endif
+else
+   ypwhich >&/dev/null
+   if ($status == 0 || -e /etc/passwd.dir || -e /etc/pwd.db) then
+      set rand = 1
+   endif
+endif
+
+if ($rand == 1) then
+   echo "It looks like you have a passwd file that can be accessed at random."
+   set pr = 'Do you want top to take advantage of this'
+else
+   echo "It looks like you have conventional passwd file access.  Top can take"
+   echo "advantage of a random access passwd mechanism if such exists.  Do"
+   echo "you want top to assume that accesses to the file /etc/passwd are done"
+   set pr = 'with random access rather than sequential'
+endif
+
+if ($nodefaults == 1) then
+   set random = $rand
+endif
+
+./getans "${pr}?" yesno $random .$$
+set random = `cat .$$`
+
+echo ""
+echo "Compiling prime.c"
+$Cmdcc $cdefs -o prime prime.c -lm



Home | Main Index | Thread Index | Old Index