erlang - open_port doesn't work when `exit_status` option not used -


when call open_port without exit_status in example below unusable:

eshell v5.7.5  (abort ^g) 1>  p = open_port({spawn, "cat >bar"}, [stream, use_stdio]). #port<0.498> 2> port_command(p, "hello\n"). ** exception error: bad argument      in function  port_command/2         called port_command(#port<0.498>,"hello\n") 

but when add exit_status , leave same works:

eshell v5.7.5  (abort ^g) 1> p = open_port({spawn, "cat >bar"}, [stream, use_stdio, exit_status]). #port<0.498> 2> port_command(p, "hello\n"). true 

from documentation don't understand difference in behaviour.

when redirect output in file in cat >bar command shell closes stdout , erlang closes port in case because ports try consume command output default , close on eof. right way fix use out option butter71 suggested. options out, exit_status, error_to_stdout tell ports not bother stdout.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -