From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <8FB7CBFD-7334-4F9F-8C71-571DEF9FAD31@ar.aichi-u.ac.jp> References: <8FB7CBFD-7334-4F9F-8C71-571DEF9FAD31@ar.aichi-u.ac.jp> Date: Tue, 16 Feb 2016 10:56:55 -0500 Message-ID: From: Jacob Todd To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a11348e36c5754c052be52e31 Subject: Re: [9fans] file descriptor leak Topicbox-Message-UUID: 852045ec-ead9-11e9-9d60-3106f5b1d025 --001a11348e36c5754c052be52e31 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I've had this problem too, I have yet to resolve it. On Feb 16, 2016 10:54 AM, "arisawa" wrote: > 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 > =E2=80=A6 > > probably the file descriptor leak comes from dnresolve.c > > udpquery(Query *qp, char *mntpt, int depth, int patient, int inns) > { > =E2=80=A6 > msg =3D system(open("/dev/null", ORDWR), "outside= "); > =E2=80=A6 > } > > char * > system(int fd, char *cmd) > { > int pid, p, i; > static Waitmsg msg; > > if((pid =3D fork()) =3D=3D -1) > sysfatal("fork failed: %r"); > else if(pid =3D=3D 0){ > dup(fd, 0); > close(fd); > for (i =3D 3; i < 200; i++) > close(i); /* don't leak fds */ > execl("/bin/rc", "rc", "-c", cmd, nil); > sysfatal("exec rc: %r"); > } > for(p =3D waitpid(); p >=3D 0; p =3D waitpid()) > if(p =3D=3D 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 > > > > --001a11348e36c5754c052be52e31 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

I've had this problem too, I have yet to resolve it.

On Feb 16, 2016 10:54 AM, "arisawa" &l= t;arisawa@ar.aichi-u.ac.jp&= gt; wrote:
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
=E2=80=A6

probably the file descriptor leak comes from dnresolve.c

udpquery(Query *qp, char *mntpt, int depth, int patient, int inns)
{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =E2=80=A6
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 msg =3D system(open("/dev/null", ORDWR), "outside= ");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =E2=80=A6
}

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

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

fd is lost if pid > 0

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

Kenji Arisawa



--001a11348e36c5754c052be52e31--