saleyn / erlexec

Execute and control OS processes from Erlang/OTP
https://hexdocs.pm/erlexec/readme.html
Other
527 stars 139 forks source link

{stdin, File} truncates the file #114

Closed depressed-pho closed 6 years ago

depressed-pho commented 6 years ago

Trying to use {stdin, File} truncates the given file before redirecting the stdin.

% echo 'foo' > foo
% wc -l foo
4 foo
% erl -noinput -eval 'application:ensure_all_started(erlexec), exec:run("cat", [{stdin, "foo"}, sync]), init:stop().'
% wc -l foo
0 foo
saleyn commented 6 years ago

This has been fixed in the latest commit.

erl -noinput -eval 'application:ensure_all_started(erlexec), io:format("Output: ~p\n", [exec:run("cat", [{stdin, "/tmp/foo"}, sync, stdout])]), init:stop().'