[erlang-questions] spawn problem

Fernando Ipar fipar@REDACTED
Tue Mar 27 15:42:13 CEST 2007


That was it!

I increased the number of open files with ulimit and it worked.

I don't know how I didn't realize it needed two fds open for each process :)

Thanks for the help,

Fernando.

ok wrote:
>
> 508 is suspiciously close to 512, which is half of 1024.
> Doesn't it look to you as though os:cmd/1 is opening TWO files?
>
> Looking in lib/kernel/src/os.erl,
>
> 	cmd/1 -> unix_cmd/1 -> spawns unix_cmd/1 -> creates a port using  
> start_port/0
> 	-> open_port({spawn,"sh -s unix:cmd  2>&1"}, [stream])
> 	The command is then sent to the STANDARD INPUT of that new process
> 	and the STANDARD OUTPUT of the process read and returned to the  
> original caller.
>
> It would be a little clearer if the documentation for  
> erlang:open_port/2 said explicitly
> that open_port({spawn,...},[...]) used up two file descriptors, but  
> this text:
> 	use_stdio
> 	    This is only valid for {spawn, Command}.
> 	    It allows the standard input and output (file descriptors 0 and 1)
> 	    of the spawned (UNIX) process for communication with Erlang.
> does give you a strong hint.
>
> Why does os:cmd/1 send the command to the shell's standard input,
> 	sh -s unix:cmd <"your command string"  ,
> rather than
> 	sh -c "your command string" </dev/null ?
>
> Not being the author, I can't say for sure, but there is an upper  
> bound on the size of a
> command in the second case which does not apply in the first (if the  
> Command is passed as
> a string, because atoms have their own limits).
>
>   




More information about the erlang-questions mailing list