Hi Kevin,<div><br></div><div>Have tried the crypto module?</div><div><br></div><div>Perhaps the crypto:sha/1 function will solve your problem in a faster and safer way.</div><div><br></div><div>Best regards</div><div>/Daniel<br>
<br><div class="gmail_quote">On Tue, Nov 4, 2008 at 7:16 AM, Kevin <span dir="ltr"><<a href="mailto:q2h46uw02@sneakemail.com" target="_blank">q2h46uw02@sneakemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hello, this function I wrote slowly increases CPU usage if called in a<br>
fairly tight loop.  Even replacing Command<br>
with "echo hello" will not fix the problem.  I also tried called<br>
port_close but I got a weird error, I think because<br>
the port was already closed.  Is this the way its done?  So far I've<br>
found no better explanation in the books or docs?<br>
Thanks for any feedback.<br>
<br>
get_sha(Str) -><br>
<br>
    Command = "echo '" ++ Str ++ "' | sha1sum",<br>
    Port = open_port({spawn, Command}, [exit_status]),<br>
    Port ! {self(), {command, []}},<br>
    receive<br>
    {Port, {data, Data}} -><br>
            %% chop off junk at end of sha1sum output, what is that crap???<br>
            string:substr(Data, 1, string:len(Data)-4);<br>
         {Port, {exit_status, Status}} -> %% exited without a result<br>
            {error, Status}<br>
    end.<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>