*BSD News Article 3342


Return to BSD News archive

Xref: sserve comp.unix.bsd:3386 comp.bugs.4bsd:1881
Path: sserve!manuel!munnari.oz.au!mips!mips!sdd.hp.com!cs.utexas.edu!sun-barr!news2me.ebay.sun.com!cronkite.Central.Sun.COM!texsun!digi!harlie!mitch
From: mitch@harlie.lonestar.org (Mitch Mitchell)
Newsgroups: comp.unix.bsd,comp.bugs.4bsd
Subject: Re: Ooops. looks like 'ps aux' problem isn't solved after all
Message-ID: <Bsnt0B.58@harlie.lonestar.org>
Date: 8 Aug 92 09:57:31 GMT
References: <1992Aug7.143505.19661@agora.uucp>
Organization: Motorcycle Riders Anonymous
Lines: 50

davidg@agora.rain.com (David Greenman) writes:
>   I really thought that I had found the problem...but after putting
>the machine through a heavy load, 'ps aux' starts failing again. The only
>difference now is that it seems to work longer after I boot the machine.
>....any suggestions?

    I've not been able to follow the thread on ps aux failure completely,
    but after running some tests with gdb, I've found the the offending
    code is in the routine that sorts the output based upon CPU usage.
    In the function getpcpu, the line:

	return (100.0 * fxtofl(p->p_pctcpu) /
		(1.0 - exp(p->p_time * log(fxtofl(ccpu)))));

    seems to cause the exception.  I've noticed that ps -auxm (sort
    by memory useage) does not fail.  Also, "ps -gvx" (which does not
    normally fail) will generate the exception if invoked as ps -gvxr (again,
    sort by cpu usage).  I put several printf statements in the code
    and each time it failed in the write() call. I didn't bother chasing
    down the range & domain information for the values displayed -- my math
    books are packed away.

    I'll make a wild guess here and say it looks like perhaps the signal
    is not delivered to the process until it makes a system call following
    the exception.  Any comments on this possibility?

    As a temporary workaround I've removed the "sortby = SORTCPU;" statement
    in ps.c for the case 'u' option.


    On a related note: the "trs" keyword should not be in the vfmt array
    if NEWVM is defined - see below:


*** ps.c.std	Sat Aug  8 04:53:11 1992
--- ps.c	Sat Aug  8 04:54:42 1992
***************
*** 86,92 ****
--- 86,96 ----
  char   o2[] = "tt state time command";
  char ufmt[] = "user pid %cpu %mem vsz rss tt state start time command";
  char vfmt[] =
+ #ifndef NEWVM
  	"pid state time sl re pagein vsz rss lim tsiz trs %cpu %mem command";
+ #else
+ 	"pid state time sl re pagein vsz rss lim tsiz %cpu %mem command";
+ #endif
  
  main(argc, argv)
  	int argc;