Re: [fpc-pascal] Unbuffering I/O
On Wednesday 29 August 2018 17:01:54 Mark Morgan Lloyd wrote: > I think I've seen this question asked before, my apologies if this was > recently. > > I've got two programs intended to be functionally identical, one in Perl > and the other in FPC. They read a unix-domain datagram, decode the > message, and emit output; if this goes to a file then it's reasonable to > monitor it using tail -f > > Perl has a variable that you can set to force output to be unbuffered, > with the result that as soon as a message is output it's in the file in > its entirety. > > Is there an equivalent for Pascal, or should I be using something like > fpSync(stdout) at opportune times? In order to flush textfiles automatically I use " ttextrec().flushfunc:= ttextrec().inoutfunc; " after it is opened. Martin ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Unbuffering I/O
On 08/29/2018 11:49 AM, Henry Vermaak wrote: Otherwise you'll have to Flush() them manually, which is a pain. really? i wrote a wrapper for write and writeln that simply calls them and then does a flush()... nothing painful other than using mywrite() and mywriteln() or similar ;) -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.* ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Unbuffering I/O
On 08/29/2018 11:01 AM, Mark Morgan Lloyd wrote: Is there an equivalent for Pascal, or should I be using something like fpSync(stdout) at opportune times? flush(); i use it all the time on my programs that write to the logs... i hate having a crash and be missing some log output because it was buffered and lost with the crash... flush() everything... -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.* ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Unbuffering I/O
Am 29.08.2018 um 18:25 schrieb Mark Morgan Lloyd: On 29/08/18 16:00, Henry Vermaak wrote: On Wed, Aug 29, 2018 at 03:01:54PM +, Mark Morgan Lloyd wrote:> I think I've seen this question asked before, my apologies if this was> recently.> > I've got two programs intended to be functionally identical, one in Perl and> the other in FPC. They read a unix-domain datagram, decode the message, and> emit output; if this goes to a file then it's reasonable to monitor it using> tail -f> > Perl has a variable that you can set to force output to be unbuffered, with> the result that as soon as a message is output it's in the file in its> entirety.> > Is there an equivalent for Pascal, or should I be using something like> fpSync(stdout) at opportune times? Does SetTextBuf() with a buffer of size 1 work? I don't think there isanything equivalent to setvbuf(). Otherwise you'll have to Flush() themmanually, which is a pain. I'm a bit wary of SetTextBuf() with a preopened handle. Flush() is actually no big deal since the program has a well-defined processing loop... but unfortunately is less than effective. It's something I can live with, since this is really only a test program I knocked together to look at how clock_gettime() behaves on different platforms (the answer being "badly" :-) SetTextBuf() does not influence the handle itself, only the buffer of the file/text record, so it should be safe to use. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Unbuffering I/O
On 29/08/18 16:00, Henry Vermaak wrote: On Wed, Aug 29, 2018 at 03:01:54PM +, Mark Morgan Lloyd wrote:> I think I've seen this question asked before, my apologies if this was> recently.> > I've got two programs intended to be functionally identical, one in Perl and> the other in FPC. They read a unix-domain datagram, decode the message, and> emit output; if this goes to a file then it's reasonable to monitor it using> tail -f> > Perl has a variable that you can set to force output to be unbuffered, with> the result that as soon as a message is output it's in the file in its> entirety.> > Is there an equivalent for Pascal, or should I be using something like> fpSync(stdout) at opportune times? Does SetTextBuf() with a buffer of size 1 work? I don't think there isanything equivalent to setvbuf(). Otherwise you'll have to Flush() themmanually, which is a pain. I'm a bit wary of SetTextBuf() with a preopened handle. Flush() is actually no big deal since the program has a well-defined processing loop... but unfortunately is less than effective. It's something I can live with, since this is really only a test program I knocked together to look at how clock_gettime() behaves on different platforms (the answer being "badly" :-) -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Unbuffering I/O
On Wed, Aug 29, 2018 at 03:01:54PM +, Mark Morgan Lloyd wrote: > I think I've seen this question asked before, my apologies if this was > recently. > > I've got two programs intended to be functionally identical, one in Perl and > the other in FPC. They read a unix-domain datagram, decode the message, and > emit output; if this goes to a file then it's reasonable to monitor it using > tail -f > > Perl has a variable that you can set to force output to be unbuffered, with > the result that as soon as a message is output it's in the file in its > entirety. > > Is there an equivalent for Pascal, or should I be using something like > fpSync(stdout) at opportune times? Does SetTextBuf() with a buffer of size 1 work? I don't think there is anything equivalent to setvbuf(). Otherwise you'll have to Flush() them manually, which is a pain. Henry ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Unbuffering I/O
I think I've seen this question asked before, my apologies if this was recently. I've got two programs intended to be functionally identical, one in Perl and the other in FPC. They read a unix-domain datagram, decode the message, and emit output; if this goes to a file then it's reasonable to monitor it using tail -f Perl has a variable that you can set to force output to be unbuffered, with the result that as soon as a message is output it's in the file in its entirety. Is there an equivalent for Pascal, or should I be using something like fpSync(stdout) at opportune times? -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal