Date: Sun, 10 Jun 2001 20:56:39 +0800 From: "Ming-I Hsieh" <mihs@wmlab.csie.ncu.edu.tw> To: <hackers@FreeBSD.ORG> Subject: a bug in ipfstream under FreeBSD 4.3-RELEASE? Message-ID: <001901c0f1ac$cb716890$2a9c738c@mihs>
next in thread | raw e-mail | index | archive | help
In one case, I need to analyse the data flow of FreeBSD box. Therefore, I
uses ipfstream to get report from 'ipfw show'. After program runs several
days, I notes some odd number in kern.openfiles. I uses fstat to find out
what thing is happened. Then I find my program does *not* release the fd
after the ipfstream has droped. Now I uses popen and pclose to replace
ipfstream. It works fine. Anyone know what thing happens? Is it a bug for
pfstream? Or just my fault. The testing program is below. Thanks.
//--------------------------------------------------------------------------
-
// pfstream bug?
//--------------------------------------------------------------------------
-
#include <pfstream.h>
#include <iostream>
#include <sysexits.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
//--------------------------------------------------------------------------
-
int main(int argc, char ** argv)
{
if (argc < 3) {
cerr.form("Usage: %s trynum sleep_time\n", argv[0]);
return EX_USAGE;
}
register int i = 0, iend = atoi(argv[1]);
for (i = 0; i < iend; i++) {
ipfstream pfin("|/bin/ls /bin", ios::in);
char buffer[1024];
// Read data from pfin
while (pfin.getline(buffer, 1024)) {
// Do nothing.
}
}
cout.form("Try \"fstat -p %d\"\n", getpid());
cout.form("Ok! Go to Sleep. [%d sec]\n", atoi(argv[2]));
sleep(atoi(argv[2]));
return EX_OK;
}
//--------------------------------------------------------------------------
-
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001901c0f1ac$cb716890$2a9c738c>
