<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link href="chrome://translator/skin/floatingPanel.css"
type="text/css" rel="stylesheet">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div dir="ltr">
<div class="gmail_default"
style="font-family:arial,helvetica,sans-serif">I fixed the
STDOUT buffering issue with erlexec. Now all STDOUT and STDERR
output should arrive as soon as the child OS process generates
it:<br>
<br>
<small><small><font face="Courier New, Courier, monospace">1>
exec:start([]).</font></small></small></div>
<div class="gmail_default"><small><small><font face="Courier New,
Courier, monospace">{ok, <0.35.0>}</font></small></small></div>
<div class="gmail_default">
<div class="gmail_default"><small><small><font face="Courier
New, Courier, monospace">2> exec:run("for i in 1 2 3;
do sleep 1; echo \"Iter$i\"; done", [{stdout,
fun(S,OsPid,D) -> io:format("Got ~w from ~w: ~p\n",
[S,OsPid,D]) end}]).</font></small></small></div>
<small><small><font face="Courier New, Courier, monospace">
</font></small></small>
<div class="gmail_default"><small><small><font face="Courier
New, Courier, monospace">{ok,<0.37.0>,2452}</font></small></small></div>
<div class="gmail_default"><small><small><font face="Courier
New, Courier, monospace">Got stdout from 2452:
<<"Iter1\n">></font></small></small></div>
<small><small><font face="Courier New, Courier, monospace">
</font></small></small>
<div class="gmail_default"><small><small><font face="Courier
New, Courier, monospace">Got stdout from 2452:
<<"Iter2\n">></font></small></small></div>
<div class="gmail_default"><small><small><font face="Courier
New, Courier, monospace">Got stdout from 2452:
<<"Iter3\n">></font></small></small></div>
</div>
</div>
<div class="gmail_extra"><br>
See <a href="https://github.com/saleyn/erlexec">https://github.com/saleyn/erlexec</a>.<br>
<br>
<div class="gmail_quote">On Wed, Aug 7, 2013 at 3:36 AM,
OvermindDL1 <span dir="ltr"><<a
href="mailto:overminddl1@gmail.com" target="_blank">overminddl1@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Created a complete test-case example of my
issue with erlexec, and I ran this same script on 3
different computers running variations of debian versions.
Feel free to toss in application:start(sasl), at the top of
the erlang script area if you wish, and yes the (minecraft)
server software uses stderr instead of stdout, no I do not
know why, and yes as you can see it does not return anything
to the erlang system until it is killed on all the systems I
tested. Using Erlang's ports you get each line as a message
as that is how the server flushes it and it is instant.
<div>
<br>
</div>
<div><br>
</div>
<div>Yes it is ugly, but it is pared down from what it grew
from and no need to re-do the receive's better in such a
test.</div>
<div>test_exec_mc.sh</div>
<div>"""</div>
<div>
<div>
#!/bin/sh</div>
<div><br>
</div>
<div>[ -d erlexec ] || git clone <a
href="https://github.com/saleyn/erlexec.git"
target="_blank">https://github.com/saleyn/erlexec.git</a></div>
<div><br>
</div>
<div>cd erlexec</div>
<div><br>
</div>
<div>rebar compile</div>
<div><br>
</div>
<div>[ -f 'minecraft_server.1.6.2.jar' ] || wget '<a
href="https://s3.amazonaws.com/Minecraft.Download/versions/1.6.2/minecraft_server.1.6.2.jar"
target="_blank">https://s3.amazonaws.com/Minecraft.Download/versions/1.6.2/minecraft_server.1.6.2.jar</a>'</div>
<div><br>
</div>
<div>erl -pa $PWD/ebin -eval '</div>
<div>application:start(exec),</div>
<div>{_, P, _} = exec:run_link("java -Xms1G -Xmx1G -jar
minecraft_server.1.6.2.jar nogui", [{stdout, self()},
{stderr, self()}]),</div>
<div>timer:sleep(1000),</div>
<div>receive A0 -> io:format("Message ~p: ~p~n",
[now(), A0]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A1 -> io:format("Message ~p: ~p~n",
[now(), A1]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A2 -> io:format("Message ~p: ~p~n",
[now(), A2]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A3 -> io:format("Message ~p: ~p~n",
[now(), A3]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A4 -> io:format("Message ~p: ~p~n",
[now(), A4]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>timer:sleep(1000),</div>
<div>receive A5 -> io:format("Message ~p: ~p~n",
[now(), A5]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A6 -> io:format("Message ~p: ~p~n",
[now(), A6]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A7 -> io:format("Message ~p: ~p~n",
[now(), A7]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A8 -> io:format("Message ~p: ~p~n",
[now(), A8]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A9 -> io:format("Message ~p: ~p~n",
[now(), A9]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>timer:sleep(10000),</div>
<div>receive A10 -> io:format("Message ~p: ~p~n",
[now(), A10]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A11 -> io:format("Message ~p: ~p~n",
[now(), A11]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A12 -> io:format("Message ~p: ~p~n",
[now(), A12]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A13 -> io:format("Message ~p: ~p~n",
[now(), A13]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A14 -> io:format("Message ~p: ~p~n",
[now(), A14]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>exec:kill(P, 9),</div>
<div>receive A15 -> io:format("Message ~p: ~p~n",
[now(), A15]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A16 -> io:format("Message ~p: ~p~n",
[now(), A16]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A17 -> io:format("Message ~p: ~p~n",
[now(), A17]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A18 -> io:format("Message ~p: ~p~n",
[now(), A18]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A19 -> io:format("Message ~p: ~p~n",
[now(), A19]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>timer:sleep(1000),</div>
<div>receive A20 -> io:format("Message ~p: ~p~n",
[now(), A20]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A21 -> io:format("Message ~p: ~p~n",
[now(), A21]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A22 -> io:format("Message ~p: ~p~n",
[now(), A22]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A23 -> io:format("Message ~p: ~p~n",
[now(), A23]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>receive A24 -> io:format("Message ~p: ~p~n",
[now(), A24]) after 1000 -> io:format("timeout ~p~n",
[now()]) end,</div>
<div>q().'</div>
</div>
<div>"""</div>
<div><br>
</div>
<div>
<br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Tue, Aug 6, 2013 at 10:49 PM,
OvermindDL1 <span dir="ltr"><<a
href="mailto:overminddl1@gmail.com" target="_blank">overminddl1@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Excepting this, is there any other better
way to launch a program as another user? I might just
use ssh certs and ssh to localhost if not unless any
other ideas?</div>
<div>
<div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">
On Tue, Aug 6, 2013 at 4:22 AM, OvermindDL1 <span
dir="ltr"><<a
href="mailto:overminddl1@gmail.com"
target="_blank">overminddl1@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir="ltr">I have been attempting to use
ErlExec as I noticed that it had a few new
features added six days ago to forward the
stdout/stderr to an Erlang PID, however I am
having some issue. The process that erlexec
runs occasionally does not die when the
Erlang VM dies, thus keeping it and its
children running.
<div>
<br>
</div>
<div>Also I need a way to send commands back
to the children, but I am either not
seeing a command for that or have not
figured out the format to send a message,
which is difficult because of the main
issue I have, when I have it launch a
fairly large server software (that is not
a daemon for whatever reason, hence why I
am wrapping it), the Erlang shell seems to
lose a great deal of input that I type in,
only catching from every 1 in 4 I type to
1 in 400 characters I type, and it does
not seem to matter based on the speed I
hit keys or holding a key or anything of
the sort, just purely on keypress down,
and it remains like that until I kill the
child process that I started through
erlexec.</div>
<div><br>
</div>
<div>Using the normal Erlang Ports works
fine and has no such issues (other than
the child not coming down with the VM
either and no direct kill command when the
child hangs, which it occasionally does,
but os:cmd("kill ...") works around that
well enough.</div>
<div><br>
</div>
<div>Is ErlExec stable enough for high use?
Or am I doing something wrong?</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions"
target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<div style="bottom: auto; left: 288px; right: auto; top: 240px;
display: none;" class="translator-theme-default"
id="translator-floating-panel">
<div title="Click to translate"
id="translator-floating-panel-button"></div>
</div>
</body>
</html>