system calls and threading question

Samuel Rivas samuel@REDACTED
Tue May 30 16:59:22 CEST 2006


Yariv Sadan wrote:
> >  os:cmd does not make system calls itself; it creates a port, so the
> >system call is invoked in a separate os thread (that is, outside the
> >erlang runtime).
> 
> Thanks for the response. That's what I expected, but I wanted to make sure 
> :)
> 
> By the way, is this how *all* native calls are handled, even
> "lightweight" ones such as erlang:date(), or are only potentially
> expensive calls handled in a different system thread?

  Well, that would depend on the implementation. It just happens that
os:cmd(Command) simply:

  "Executes Command in a command shell of the target OS, captures the
  standard output of the command and returns this result as a string"

  That has nothing to do with "native calls", you can execute anything
you can run from an OS shell:

1> os:cmd("make").
"make: *** No targets specified and no makefile found.  Stop.\n"

  Aside, erland:date() is a bif, so I'd bet it is pretty efficient. 
-- 
	Samuel



More information about the erlang-questions mailing list