Minimal embedded Erland system

Joe Armstrong joe@REDACTED
Thu Sep 23 11:15:13 CEST 1999

On Thu, 23 Sep 1999, Klacke wrote:

>  > I make a boot script using systools:make_script() and start the system
>  > using "erl -boot test -mode embedded -pz /home/jfk/test/ebin". The
> If you replace the "-mode embedded " with -noshell, the shell isn't
> started. (Also note that the erlc compiler knows how to compile
> .rel files, we can just call erlc test.rel to produce the script+boot
> files.)
> An even easier way to make a small script to run your erlang code is
> erl -noshell -s test
>  > shell, write something to standard output and then exit to the Unix
> io:format(... writes to stdout, halt() exits the erlang system back
> to the unix shell.
> There is no _easy_ way to write to stderr.
> /klacke

If you want to make a minimal system you should not use io but
hit the IO file descriptors *directly* here is cat.erl
which does this:

main(_) ->  
    Port = erlang:open_port_prim({fd,0,1}, [eof, binary]),
loop(Port) ->
    case read(Port) of
         eof ->
         {ok, X} ->
             write(Port, [X]),

read(Port) ->
       {Port, {data, Bytes}} ->
           {ok, Bytes};
       {Port, eof} ->
write(Port, X) ->
    Port ! {self(), {command, X}}.
If the next release of OSE contains the shared library
and tiny application builder
code stuff then this will compile to a 872 byte executable.

<<is this in the next release Björn???>>


Joe Armstrong,                       
Bluetail AB,                           tel:  +46 8 692 22 11
Hantverkargatan 78,                    fax:  +46 8 654 70 71
SE-112 38 Stockholm, Sweden            info:

More information about the erlang-questions mailing list