Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: addmodulefd(..., FDT_INTERNAL or FDT_MODULE);



On Jun 14,  7:12am, Sebastian Gniazdowski wrote:
}
} I read whole 36870 topic ("Mangement of fdtable[]") and it's hard
} to get insight on FDT_INTERNAL vs. FDT_MODULE. I now follow initial
} db_gdbm.c code which used FDT_INTERNAL. Is it a good choice?

FDT_MODULE means two things:
(1) The user can't "accidentally" close the descriptor with {fd}>&-
(2) The shell will NOT close the descriptor upon exec(), so it is
    left available for use by external child processes

} I think both gdbm and redis support cloned file descriptor on fork(),
} because test cases work fine - database-store in subshell works
} correctly. This also points that file descriptor isn't closed when
} using FDT_INTERNAL with addmodulefd().

Correct, FDT_INTERNAL descriptors are not closed on fork(), but if the
fork() is followed by an exec() they will be closed.  You can share the
descriptor with a subshell but not with an external command.

So it's up to the module implementor to decide which behavior is the
correct one for his module.



Messages sorted by: Reverse Date, Date, Thread, Author