From owner-freebsd-current Tue Oct 6 18:15:29 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA19418 for freebsd-current-outgoing; Tue, 6 Oct 1998 18:15:29 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from picnic.mat.net (picnic.mat.net [206.246.122.117]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA19286 for ; Tue, 6 Oct 1998 18:14:53 -0700 (PDT) (envelope-from chuckr@mat.net) Received: from localhost (chuckr@localhost) by picnic.mat.net (8.9.1/8.8.5) with ESMTP id VAA21092; Tue, 6 Oct 1998 21:14:10 -0400 (EDT) Date: Tue, 6 Oct 1998 21:14:10 -0400 (EDT) From: Chuck Robey To: Alex cc: current Subject: Re: Something else seems to be leaking... In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 6 Oct 1998, Alex wrote: > Welp. I finally got aorund to toying with kcminfo (some obscure thing > from KDE), and it's leaking like a sieve. Naturally I think that it's to > blame, however I've managed to narrow it down to a few lines of code > (which have been reported to not leak on -stable): > > /* Q&D hack for swap display. Borrowed from xsysinfo-1.4 */ > if ((pipe = popen("/usr/sbin/pstat -ks", "r")) == NULL) { > used = total = 1; > return; > } > fgets(buf, sizeof(buf), pipe); > fgets(buf, sizeof(buf), pipe); > fgets(buf, sizeof(buf), pipe); > fgets(buf, sizeof(buf), pipe); > strtok(buf, " "); > total_str = strtok(NULL, " "); > used_str = strtok(NULL, " "); > pclose(pipe); This might have nothing to do with your leak, but never do consecutive calls to strtok, when using NULL as first param, without checking if the previous return was also NULL. You might well have run off the end of the string, and sent strtok off into never never land. Surprising this hasn't caused SEGVs. > > Commenting everything but the popen and pclose things, doesn't seem to fix > anything. This is called from some sort of timer every second or so, so > the leak is rather apparent. > > - alex > > | "Contrary to popular belief, penguins are not the salvation of modern | > | technology. Neither do they throw parties for the urban proletariat." | > | Powered by FreeBSD http://www.freebsd.org/ | > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-current" in the body of the message > > ----------------------------+----------------------------------------------- Chuck Robey | Interests include any kind of voice or data chuckr@glue.umd.edu | communications topic, C programming, and Unix. 213 Lakeside Drive Apt T-1 | Greenbelt, MD 20770 | I run Journey2 and picnic (FreeBSD-current) (301) 220-2114 | and jaunt (NetBSD). ----------------------------+----------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message