zsh-workers
 help / color / mirror / code / Atom feed
* addmodulefd(..., FDT_INTERNAL or FDT_MODULE);
@ 2017-06-14  5:12 Sebastian Gniazdowski
  2017-06-14 23:16 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2017-06-14  5:12 UTC (permalink / raw)
  To: zsh-workers

Hello,
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?

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().

To note, hiredis (unlike libsqlite3) exposes file descriptor in redisContext::fd field, so it's nice that gdbm and redis behave the same.
--
Sebastian Gniazdowski
psprint /at/ zdharma.org


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

* Re: addmodulefd(..., FDT_INTERNAL or FDT_MODULE);
  2017-06-14  5:12 addmodulefd(..., FDT_INTERNAL or FDT_MODULE); Sebastian Gniazdowski
@ 2017-06-14 23:16 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2017-06-14 23:16 UTC (permalink / raw)
  To: zsh-workers

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.


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

end of thread, other threads:[~2017-06-14 23:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-14  5:12 addmodulefd(..., FDT_INTERNAL or FDT_MODULE); Sebastian Gniazdowski
2017-06-14 23:16 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).