Date: Wed, 17 Sep 1997 10:06:47 +0200 (SAT) From: Graham Wheeler <gram@cdsec.com> To: phk@critter.freebsd.dk (Poul-Henning Kamp) Cc: hackers@freebsd.org Subject: Re: Memory leak in getservbyXXX? Message-ID: <199709170806.KAA02083@cdsec.com> In-Reply-To: <7153.874473906@critter.freebsd.dk> from "Poul-Henning Kamp" at Sep 17, 97 07:25:06 am
next in thread | previous in thread | raw e-mail | index | archive | help
(I've stopped cc-ing to freebsd-bugs on the assumption that the bug is mine). Unfortunately the problem hasn't gone away. This morning the program was spinning again, along with about ten child processes. This is really weird, especially as all the child processes do is a gethostbyaddr(), write the result to a (pipe) file descriptor, and exit. Here is some code, if this sheds any light (these are all virtual methods): int ChildProcess::Spawn() { if (ChildManager::Register(this) >= 0) { if ((pid = fork()) == 0) { exit(Run()); } else if (pid>0) { state = Running; starttime = Time(); return 0; } } state = Failed; return -1; } // PipeChildProcess inherits from ChildProcess int PipeChildProcess::Spawn() { if (socketpair(AF_UNIX, SOCK_STREAM, 0, pfd) < 0) { state = Failed; return -1; } int rtn = ChildProcess::Spawn(); if (rtn < 0) close(pfd[0]); else pipefd = pfd[0]; close(pfd[1]); return rtn; } int PipeChildProcess::Run() { close(pfd[0]); pipefd = pfd[1]; // set standard descriptors to be pipe for (int i = 0; i < 3; i++) if (i != pipefd) if (dup2(pipefd, i) < 0) return -1; return Exec(); } // DNSLookupProcess inherits from PipeChildProcess int DNSLookupProcess::Exec() { unsigned char *cp = (unsigned char *)&addr; printf("%c%c%c%c", cp[0], cp[1], cp[2], cp[3]); struct in_addr a; a.s_addr = addr; struct hostent *h = gethostbyaddr((char*)&a, 4, AF_INET); if (h) { printf("%s", h->h_name); return 0; } return (-1); } -- Dr Graham Wheeler E-mail: gram@cdsec.com Citadel Data Security Phone: +27(21)23-6065/6/7 Internet/Intranet Network Specialists Mobile: +27(83)-253-9864 Firewalls/Virtual Private Networks Fax: +27(21)24-3656 Data Security Products WWW: http://www.cdsec.com/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709170806.KAA02083>