From mboxrd@z Thu Jan 1 00:00:00 1970 From: arisawa Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-Id: <8FB7CBFD-7334-4F9F-8C71-571DEF9FAD31@ar.aichi-u.ac.jp> Date: Wed, 17 Feb 2016 00:52:37 +0900 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: [9fans] file descriptor leak Topicbox-Message-UUID: 851bad0c-ead9-11e9-9d60-3106f5b1d025 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