linked-in drivers once again

Raimo Niskanen raimo@REDACTED
Thu Jun 28 10:35:35 CEST 2001

Vance Shipley wrote:
> > - I use the following statement:
> > Port = open_port({spawn, "./"}, [])
> > instead of using the statement:
> > Port = open_port({spawn, "easiest_drv"},[])
> > The first statement works, the latter does not. Yet I am confused
> > because all the examples I have seen follow the second convention.
> Why the former works is a fluke.  

A fluke and an ugly behaviour with open_port/2. The function
open_port({spawn, Command}, []) was originally used for opening a port
that communicates with an external program - Command, and then reused
for opening a port that is an instance of a port driver - Command. So we
have a namespace clash here. If there exists a port driver named 'foo'
you cannot call an external program (port program) named 'foo' - it is
shadowed by the driver (or is it the other way around?)

What probably happens in "the former case" is that a port is opened (an
instance of the built in 'spawn' driver) that tries to execute
"./" in another unix process, which fails and the port
dies. Therefore you get a port, but it is closed when you try to use it.

/ Raimo Niskanen, Ericsson UAB, Erlang/OTP

More information about the erlang-questions mailing list