#4 fork problem


When IAXmodem runs with daemon mode on FreeBSD 6.1-
Release, I found the problem.
A lot of child processes increase...
I saw the source code, and found the cause.
Because after fork(), the child process closedir()
while parent process's opendir() and using it.
Please correct...


  • Lee Howard

    Lee Howard - 2006-09-06

    Logged In: YES

    Do you have a proposed code change that resolves the matter
    for you? If not, why do you conclude that the problem is
    with the child calling closedir?

    Here's part of the reponse that I received from Julien
    Blache, the author of the forking code:

    IBM manpages for AIX tell that if you fork() with an open
    directory, either one of the parent or child can continue
    working on it, but not both. They do not mention closedir()
    so it looks like calling closedir() should be safe too (they
    explicitely mention readdir, seekdir, rewinddir).

    Either it's a bug in the FreeBSD libc, or the GNU libc is
    once again non-standard, or there is something else. Though
    I'll accept that it's a bug in my code ;)

    Adding an else branch to the if statement just below the
    closedir() call and moving it in there should fix it on
    FreeBSD, if it's the real problem.

  • Lee Howard

    Lee Howard - 2006-09-21
    • status: open --> closed