Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!ux1.cso.uiuc.edu!csrd.uiuc.edu!sp1.csrd.uiuc.edu!kai From: kai@sp1.csrd.uiuc.edu (Kuck And Associates) Newsgroups: comp.sys.sgi Subject: Irix 3.3.1 C problem - can't display load averages Message-ID: <1990Nov27.190305.9267@csrd.uiuc.edu> Date: 27 Nov 90 19:03:05 GMT Sender: news@csrd.uiuc.edu (news) Distribution: comp Organization: UIUC Center for Supercomputing Research and Development Lines: 98 Here is a short program which, when compiled under Irix 3.2, runs and displays the load averages on both Irix 3.2 and, interestingly, 3.3.1. However, when compiled under Irix 3.3.1, it quits after nlist() with the error message "lseek: Invalid argument". Patrick Wolfe (pwolfe@kai.com, kailand!pwolfe) System Programmer/Operations Manager, Kuck & Associates #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'loadavg.c' <<'END_OF_FILE' X#include X#include X#include X Xchar KmemName[] = "/dev/kmem"; Xchar UnixName[] = "/unix"; Xchar AvenrunSym[] = "avenrun"; X Xmain () X{ Xstruct nlist nl[2]; Xdouble loadav[3]; Xint kmemf; X Xif ((kmemf = open (KmemName, O_RDONLY)) == -1) { X perror ("open"); X exit (1); X } X Xnl[0].n_name = AvenrunSym; Xnlist (UnixName, nl); Xif (nl[0].n_type == 0 || nl[0].n_value == 0) { X perror ("nlist"); X exit (1); X } X Xif (lseek (kmemf, nl[0].n_value, 0) == -1) { X perror ("lseek"); X exit (1); X } X Xif (read (kmemf, loadav, sizeof (loadav)) != sizeof (loadav)) { X perror ("read"); X exit (1); X } X Xprintf ("%04.2f %04.2f %04.2f\n", (double) loadav[0], X (double) loadav[1], (double) loadav[2]); Xexit (0); X} END_OF_FILE if test 707 -ne `wc -c <'loadavg.c'`; then echo shar: \"'loadavg.c'\" unpacked with wrong size! fi # end of 'loadavg.c' fi if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(321 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' XCFLAGS = -g XSHELL = /bin/sh X Xloadavg: loadavg.o Makefile X $(CC) $(CFLAGS) -o loadavg loadavg.o -lmld X @echo "you might need to be root to do the next command" X chgrp sys loadavg X chmod 2755 loadavg X Xclean: X rm -f a.out core mklog loadavg loadavg.shar *.o X Xshar: loadavg.c Makefile X shar loadavg.c Makefile > loadavg.shar END_OF_FILE if test 321 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi echo shar: End of shell archive. exit 0