Re: very strange problem with ps
According to Brooks Davis: > I'm seeing a very strange problem with ps. I was calling "ps -U Speaking of ps, since we moved into SMPng, almost all processes seems to have the 'D' state... I guess it is expected but a little strange, no? 388 [13:28] roberto@sidhe:~> ps aux USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND root 10 93.4 0.0 00 ?? RWL 5:31PM 19:14.98 (idle) roberto 813 3.0 2.9 6700 1381 ?? Ds1:12PM 0:17.07 deskguide_applet roberto 881 4.0 1.2 2440 557 p3 DWs 1:28PM 0:00.23 -zsh (zsh) [ skipping irq threads ] root2 0.0 0.0 00 ?? DWL 5:31PM 0:00.01 (pagedaemon) root3 0.0 0.0 00 ?? DWL 5:31PM 0:00.00 (vmdaemon) root4 0.0 0.0 00 ?? DWL 5:31PM 0:00.01 (bufdaemon) root5 0.0 0.0 00 ?? DWL 5:31PM 0:00.16 (syncer) root 201 0.0 0.2 444 79 ?? DWs 5:33PM 0:00.09 pccardd -f /etc/ root 237 0.0 0.3 984 165 ?? DWs 5:33PM 0:00.08 syslogd -s root 242 0.0 0.5 1332 243 ?? DW
Re: very strange problem with ps
On Sat, Mar 17, 2001 at 10:02:16AM +, David Malone wrote: > On Fri, Mar 16, 2001 at 06:21:46PM -0800, Brooks Davis wrote: > > Ah, you are correct. I should have tried that. What a strange bug. > > It happens for any option which causes the sysctl to return no > processes to libkvm. (Try ps -p 10). I think the following > patch should fix the problem. I think that should do it. I was testing a slightly different fix, but that one looks clearner. Part of the problem is that kvm_getprocs has a completly stupid API. Since it's reasionable that you could get no entries from your query, you damn well should be able to return the appropriate pointer (NULL) but someone wasn't thinking very hard and NULL is the error condition. -- Brooks -- Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 PGP signature
Re: very strange problem with ps
> I actually prefer the ESRCH patch as a) it better describes what happens and b > it returns a proper error when no processes are found, making it easier for > other programs to detect this error condition. Programs should already be > checking for a error return from the sysctlbyname() that they use to get this > (or else they allow for kvm to inform them of errors) and thus won't need to > add in special case checks for 'size > 0'. errno is the standard way of > returning errors after all. :) It depends what you consider the sysctl to do - if it's job is returning a list of all processes belonging to a user and there aren't any then returning a list of length zero seems a reasonable thing to do. It's not that the list doesn't exist, it's that it is empty. Afterall strlen doesn't return an error for a string of length zero. ;-) Actually, I'm not all that fussed. I just think it's more likely that the new check is incorrect than go changing other code which seems to have been working fine. David. To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Re: very strange problem with ps
On 17-Mar-01 David Malone wrote: > On Fri, Mar 16, 2001 at 06:21:46PM -0800, Brooks Davis wrote: >> Ah, you are correct. I should have tried that. What a strange bug. > > It happens for any option which causes the sysctl to return no > processes to libkvm. (Try ps -p 10). I think the following > patch should fix the problem. > > (Kirk changed the way the struct proc size was checked, and the > old way happened to work OK if no data was returned. Kirk, should > I go ahead and commit this?) > > David. I actually prefer the ESRCH patch as a) it better describes what happens and b) it returns a proper error when no processes are found, making it easier for other programs to detect this error condition. Programs should already be checking for a error return from the sysctlbyname() that they use to get this (or else they allow for kvm to inform them of errors) and thus won't need to add in special case checks for 'size > 0'. errno is the standard way of returning errors after all. :) -- John Baldwin <[EMAIL PROTECTED]> -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Re: very strange problem with ps
On Fri, Mar 16, 2001 at 06:21:46PM -0800, Brooks Davis wrote: > Ah, you are correct. I should have tried that. What a strange bug. It happens for any option which causes the sysctl to return no processes to libkvm. (Try ps -p 10). I think the following patch should fix the problem. (Kirk changed the way the struct proc size was checked, and the old way happened to work OK if no data was returned. Kirk, should I go ahead and commit this?) David. Index: kvm_proc.c === RCS file: /cvs/FreeBSD-CVS/src/lib/libkvm/kvm_proc.c,v retrieving revision 1.32 diff -u -r1.32 kvm_proc.c --- kvm_proc.c 2001/02/12 00:21:09 1.32 +++ kvm_proc.c 2001/03/17 09:54:16 @@ -403,7 +403,8 @@ _kvm_syserr(kd, kd->program, "kvm_getprocs"); return (0); } - if (kd->procbase->ki_structsize != sizeof(struct kinfo_proc)) { + if (size > 0 && + kd->procbase->ki_structsize != sizeof(struct kinfo_proc)) { _kvm_err(kd, kd->program, "kinfo_proc size mismatch (expected %d, got %d)", sizeof(struct kinfo_proc), To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Re: very strange problem with ps
On Fri, Mar 16, 2001 at 06:17:37PM -0800, Alex Zepeda wrote: > On Fri, Mar 16, 2001 at 06:12:29PM -0800, Brooks Davis wrote: > > I'm seeing a very strange problem with ps. I was calling "ps -U > > >From what I can tell (I've seen this for a while), calling ps -U username > where username has no running processes (or none shown), will return such > an error. ps -U where there are processes to be shown will work fine. > *shrug* Ah, you are correct. I should have tried that. What a strange bug. -- Brooks -- Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 PGP signature
Re: very strange problem with ps
On Fri, Mar 16, 2001 at 06:12:29PM -0800, Brooks Davis wrote: > I'm seeing a very strange problem with ps. I was calling "ps -U >From what I can tell (I've seen this for a while), calling ps -U username where username has no running processes (or none shown), will return such an error. ps -U where there are processes to be shown will work fine. *shrug* - alex To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
very strange problem with ps
I'm seeing a very strange problem with ps. I was calling "ps -U operator" to check the status of some dumps and it was working fine, but then I ran it again and got a kinfo_proc size mismatch. Calling it with no args still works, but calling it with -U doesn't. This is with a current as of this morning. I'll try a rebuild after this dump finishes. You can see what I did in a transcript below. -- Brooks [6:11pm] brooks@minya (~): ps -U operator PID TT STAT TIME COMMAND 884 ?? DW 0:00.02 /usr/local/libexec/amanda/sendbackup 885 ?? RW 0:05.98 /usr/bin/gzip --fast 886 ?? DW 0:00.29 /usr/local/libexec/amanda/sendbackup 887 ?? DW 0:00.05 dump 1ushf 1048576 0 - /dev/ad0s2a 888 ?? ZW 0:00.00 (sh) 891 ?? DW 0:00.09 dump 1ushf 1048576 0 - /dev/ad0s2a 892 ?? DW 0:00.14 dump 1ushf 1048576 0 - /dev/ad0s2a 893 ?? DW 0:00.14 dump 1ushf 1048576 0 - /dev/ad0s2a 894 ?? DW 0:00.15 dump 1ushf 1048576 0 - /dev/ad0s2a [6:11pm] brooks@minya (~): ps -U operator ps: kinfo_proc size mismatch (expected 648, got 268107798) [6:12pm] brooks@minya (~): ps -U operator ps: kinfo_proc size mismatch (expected 648, got 268107798) [6:12pm] brooks@minya (~): ps -U operator ps: kinfo_proc size mismatch (expected 648, got 268107798) [6:12pm] brooks@minya (~): ps PID TT STAT TIME COMMAND 567 p0 DWs+ 0:00.17 -tcsh (tcsh) 568 p1 DWs0:00.14 -tcsh (tcsh) 608 p1 DW+0:00.17 ssh gigan 569 p2 DWs0:00.14 -tcsh (tcsh) 604 p2 DW+0:00.36 ssh odin.ac.hmc.edu 570 p3 DWs0:00.29 -tcsh (tcsh) 915 p3 RW+0:00.00 ps 514 v0 DWs0:00.17 -tcsh (tcsh) 526 v0 DW+0:00.01 /bin/sh /usr/X11R6/bin/startx 538 v0 DW+0:00.02 xinit /usr/home/brooks/.xinitrc -- -auth /usr/home/br 544 v0 DW 0:00.01 sh /usr/home/brooks/.xinitrc 561 v0 DW 0:00.52 Eterm --geometry 80x32+64+64 562 v0 DW 0:00.23 Eterm --geometry 80x32+560+64 563 v0 DW 0:00.53 Eterm --geometry 80x34+64-74 564 v0 DW 0:00.15 Eterm --geometry 80x34+560-74 566 v0 D 0:01.15 wmaker 596 v0 DW 0:08.29 wmmon 597 v0 DW 0:00.87 wmCalClock 598 v0 RW 0:11.60 wmapm 599 v0 DW 0:01.04 wmmixer -w 600 v0 DW 0:02.25 wmnet 787 v0 DW 0:12.13 /usr/local/lib/netscape-linux/communicator-4.7.bin 788 v0 DW 0:00.07 (dns helper) (communicator-4.7) [6:13pm] brooks@minya (~): -- Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 PGP signature