[erlang-questions] Passing parameters to a port driver
Per Hedeland
per@REDACTED
Tue Jan 29 22:40:10 CET 2008
Sebastian Bello <sebastian.bello@REDACTED> wrote:
>
>is there a way to pass parameters (maybe in the form of an Erlang term)
>to a port driver while creating it (open_port)? My understanding is that
>open_port launches the function
> static ErlDrvData driver_start(ErlDrvPort port, char *buff)
>
>on the port; what does "char *buff" contain?
It's the complete Command string from open_port({spawn, Command}, ...) -
i.e. you can give that as "my_drv param1 param2" and the my_drv driver
will have its start() function invoked with that exact string as its
second argument (in C form of course:-). If you look at the
driver_entry(3) man page, the argument is called 'command', which
perhaps makes this a bit more obvious.
--Per Hedeland
More information about the erlang-questions
mailing list