{active, once} for generic file descriptors

Jan Huwald <>
Thu Aug 26 23:40:34 CEST 2010

Is there a way to read from a (UNIX) file descriptor with the {active, once} 
semantics of gen_tcp?

I repeatedly used NIFs to obtain a handle (inotify, UNIX domain socket, ...), 
which I then plugged into the VM poll mechanism using open_port( ... {fd, 
Handle, _}]). But this way I introduced possible message queue overflows. To 
prevent this I'd like to imitate the convenient {active, once} behaviour.

So I'm up to writing a port driver for generic file descriptor handling, 
mimicking the gen_tcp interface. But given the need to simply do fail-safe 
I/O on a FD obtained elsewhere is a reoccuring one, I hope that someone 
already did that job, or found a better way around.


More information about the erlang-questions mailing list