eap@bu-pub.bu.edu (Eric A Pearce) (12/16/90)
This works. The basic outline is borrowed from conf.c in Sendmail 5.61 and has been modified with sgi-specific features. /* * Copyright (c) 1983 Eric P. Allman * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include <sys/types.h> #include <nlist.h> struct nlist Nl[] = { { "avenrun" }, #define X_AVENRUN 0 { 0 }, }; getla() { static int kmem = -1; long avenrun[3]; extern off_t lseek(); if (kmem < 0) { kmem = open("/dev/kmem", 0, 0); if (kmem < 0) return (-1); (void) fcntl(kmem, F_SETFD, 1); nlist("/unix", Nl); if (Nl[0].n_type == 0) return (-1); } if (lseek(kmem, (off_t) Nl[X_AVENRUN].n_value & 0x7fffffff, 0) == -1 || read(kmem, (char *) avenrun, sizeof(avenrun)) < sizeof(avenrun)) { /* thank you Ian */ return (-1); } return ((int) (avenrun[0] / 1024.0 + 0.5)); } -- ------------------------------------------------------------------------------- Eric Pearce eap@bu-pub.bu.edu Boston University Information Technology 111 Cummington Street, Boston MA 02215 617-353-2780 voice 617-353-6260 fax