9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] file descriptor leak
@ 2016-02-16 15:52 arisawa
  2016-02-16 15:56 ` Jacob Todd
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: arisawa @ 2016-02-16 15:52 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,

I have observed warning messages from dns server:
dns 30792: warning process exceeded 100 file descriptors
dns 30888: warning process exceeded 200 file descriptors
…

probably the file descriptor leak comes from dnresolve.c

udpquery(Query *qp, char *mntpt, int depth, int patient, int inns)
{
	…
			msg = system(open("/dev/null", ORDWR), "outside");
	…
}

char *
system(int fd, char *cmd)
{
	int pid, p, i;
	static Waitmsg msg;

	if((pid = fork()) == -1)
		sysfatal("fork failed: %r");
	else if(pid == 0){
		dup(fd, 0);
		close(fd);
		for (i = 3; i < 200; i++)
			close(i);		/* don't leak fds */
		execl("/bin/rc", "rc", "-c", cmd, nil);
		sysfatal("exec rc: %r");
	}
	for(p = waitpid(); p >= 0; p = waitpid())
		if(p == pid)
			return msg.msg;
	return "lost child";
}

fd is lost if pid > 0

my server is running on 9front. however both 9atom and bell-labs use same routine.

Kenji Arisawa





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-02-22  5:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-16 15:52 [9fans] file descriptor leak arisawa
2016-02-16 15:56 ` Jacob Todd
2016-02-16 16:42   ` lucio
2016-02-16 17:05     ` Jacob Todd
2016-02-16 17:17     ` Charles Forsyth
2016-02-16 18:01 ` cinap_lenrek
2016-02-16 21:05   ` erik quanstrom
2016-02-16 21:16   ` Charles Forsyth
2016-02-17  2:19     ` cinap_lenrek
2016-02-22  5:18     ` erik quanstrom
2016-02-16 22:24 ` Charles Forsyth
2016-02-17  1:13   ` arisawa
2016-02-17  1:22     ` cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).