[erlang-questions] Flush "stdout" buffer

Per Hedeland per@REDACTED
Fri Sep 1 14:58:44 CEST 2017


On 2017-09-01 13:58, Frank Muller wrote:
> Can someone help on this please?

Well, what is the problem that you want to solve? Erlang doesn't really
have an equivalent to C stdio, and anything you write with io:format/1,2,3
to "standard output" is sent immediately to the OS via a write(2) (or
typically writev(2)) call. Are you seeing something else?  Try this:

erl -noshell -eval 'io:format("foo "),timer:sleep(2000),io:format("bar~n"),timer:sleep(2000),erlang:halt(0)'

--Per

> Thanks
> /Frank
> 
> Le mer. 30 août 2017 at 07:21, Frank Muller <frank.muller.erl@REDACTED <mailto:frank.muller.erl@REDACTED>> wrote :
> 
>     Hi Prakash,
> 
>     Thanks, but I doubt it's that easy.
> 
>     In C, you've to call fflush or set the stdout to unbuffer mode.
> 
>     /Frank
> 
>     Le mer. 30 août 2017 à 06:51, Prakash Parmar <prakashkumar_parmar@REDACTED <mailto:prakashkumar_parmar@REDACTED>> wrote :
> 
>         Hi Frank,
> 
>         As per my experience, Like in C, keeping newline "~n" in io:format will flush it to screen.
> 
>         /Prakash
> 
>         -----Original Message-----
>         From: "Frank Muller" <frank.muller.erl@REDACTED <mailto:frank.muller.erl@REDACTED>>
>         Sent: Wednesday, August 30, 2017 9:58am
>         To: "Erlang-Questions Questions" <erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>>
>         Subject: [erlang-questions] Flush "stdout" buffer
> 
>         Hi guys,
>         I'd like to know if there's an equivalent function to C fflush(stdout) ?
>         I've a small Erlang program which prints data to stdout. After every io:format call, I'd like to ensure output is flushed to screen.
>         Thanks in adavance.
>         /Frank
> 
> 
> 
>         ******* DISCLAIMER: This email and any files transmitted with it are privileged and confidential information and intended solely for the use of the individual or entity to which they are
>         addressed. If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its
>         contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Torry Harris Business Solutions has taken every reasonable precaution to minimize this risk,
>         but is not liable for any damage you may sustain as a result of any virus in this e-mail. The recipient should check this email and any attachments for the presence of viruses. THBS reserves
>         the right to monitor and review the content of all messages sent to or from this e-mail address********
> 
>         ******* DISCLAIMER: This email and any files transmitted with it are privileged and confidential information and intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Torry Harris Business Solutions has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail.  The recipient should check this email and any attachments for the presence of viruses. THBS reserves the right to monitor and review the content of all messages sent to or from this e-mail address.********
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list