Sponsored Content
Top Forums Programming Sleep or Dealy fucntion Issue Post 302129922 by Jagadeeswaran.K on Thursday 2nd of August 2007 09:29:21 AM
Old 08-02-2007
Basically UNIX is Bufferred system.
It has two types of buffering system.
1) Line Buffering
2) Block Buffering.

The printf() in C uses the Linf Buffering System. It means, first the Strings are moved to a Buffer. After the Buffer moves the strings to console/memory. The Buffer is cleared, when any one of the following scenario occurs.
1) If the Buffer is full
2) new line Char "\n" occurs
3) The Buffer is flushed by fflush()
4) The Program Terminates.


from the porter's Solution
we have to use the fflush to clear the buffer.
and also we have to use "\n" in all the printf().

Ex:
printf("Hi\n");
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sleep

what is the purpose of the sleep command? (5 Replies)
Discussion started by: Anna
5 Replies

2. Shell Programming and Scripting

Sleep under one second

If I want a script to sleep for less than a second, would I use a decimal? In other words, if I wanted my script to sleep for 1/4 of a second, would I say, SLEEP .25 ?? (5 Replies)
Discussion started by: Scoogie
5 Replies

3. UNIX for Dummies Questions & Answers

system sleep

Dear All , I installed new Linux Red Hat 9 system and it is working fine . but while i keep it for certain time ideal ( i mean ndo not wrok on system itself ) it goes to mode like sleep mode ,,, but while it is in sleep mode i can not ping it or telnet !! i discovered it while i was telnet... (8 Replies)
Discussion started by: tamemi
8 Replies

4. UNIX for Dummies Questions & Answers

Sleep less than 1 second

Does anyone know a way to sleep less than 1 second? Sometimes when I write scripts that iterates a loop many times it would be nice to slow things down, but sometimes 1 second is too much. (9 Replies)
Discussion started by: bjorno
9 Replies

5. Shell Programming and Scripting

Wrapping 'sleep' with my 'resleep' function (Resettable sleep)

This is a very crude attempt in Bash at something that I needed but didn't seem to find in the 'sleep' command. However, I would like to be able to do it without the need for the temp file. Please go easy on me if this is already possible in some other way: How many times have you used the... (5 Replies)
Discussion started by: deckard
5 Replies

6. UNIX for Dummies Questions & Answers

ISSUE on SFTP fucntion ,parameter passing!

Hi Everyone!! Hey i created a SFTP function to FTP the file from unix to Linux. I need to FTP the 48 files from unix to linux. IP=$1 Userid=$2 Prikeypath=$3 SrcPath=$4 DstPath=$5 Files=$6 BATCHFILE=sftp.batch.$$ LOGFILE=sftp.log.$$ #Compose batch file & pass as argument to the... (1 Reply)
Discussion started by: bobprabhu
1 Replies

7. Shell Programming and Scripting

Sleep while i > 0

Hi, I have a script that runs a process at the beginning and I want to sleep/wait until this process is finished and then continue with the rest of the script. I am trying with this, but it is not working: process=`ps -ef | grep "proc_p01 -c" | grep -v grep | wc -l` if ; do sleep 10 done... (7 Replies)
Discussion started by: apenkov
7 Replies
Appender::Buffer(3)					User Contributed Perl Documentation				       Appender::Buffer(3)

NAME
Log::Log4perl::Appender::Buffer - Buffering Appender SYNOPSIS
use Log::Log4perl qw(:easy); my $conf = qq( log4perl.category = DEBUG, Buffer # Regular Screen Appender log4perl.appender.Screen = Log::Log4perl::Appender::Screen log4perl.appender.Screen.stdout = 1 log4perl.appender.Screen.layout = PatternLayout log4perl.appender.Screen.layout.ConversionPattern = %d %p %c %m %n # Buffering appender, using the appender above as outlet log4perl.appender.Buffer = Log::Log4perl::Appender::Buffer log4perl.appender.Buffer.appender = Screen log4perl.appender.Buffer.trigger_level = ERROR ); Log::Log4perl->init($conf); DEBUG("This message gets buffered."); INFO("This message gets buffered also."); # Time passes. Nothing happens. But then ... print "It's GO time!!! "; ERROR("This message triggers a buffer flush."); DESCRIPTION
"Log::Log4perl::Appender::Buffer" takes these arguments: "appender" Specifies the name of the appender it buffers messages for. The appender specified must be defined somewhere in the configuration file, not necessarily before the definition of "Log::Log4perl::Appender::Buffer". "max_messages" Specifies the maximum number of messages the appender will hold in its ring buffer. "max_messages" is optional. By default, "Log::Log4perl::Appender::Buffer" will not limit the number of messages buffered. This might be undesirable in long-running processes accumulating lots of messages before a flush happens. If "max_messages" is set to a numeric value, "Log::Log4perl::Appender::Buffer" will displace old messages in its buffer to make room if the buffer is full. "trigger_level" If trigger_level is set to one of Log4perl's levels (see Log::Log4perl::Level), a "trigger" function will be defined internally to flush the buffer if a message with a priority of $level or higher comes along. This is just a convenience function. Defining log4perl.appender.Buffer.trigger_level = ERROR is equivalent to creating a trigger function like log4perl.appender.Buffer.trigger = sub { my($self, $params) = @_; return $params->{log4p_level} >= $Log::Log4perl::Level::ERROR; } See the next section for defining generic trigger functions. "trigger" "trigger" holds a reference to a subroutine, which "Log::Log4perl::Appender::Buffer" will call on every incoming message with the same parameters as the appender's "log()" method: my($self, $params) = @_; $params references a hash containing the message priority (key "l4p_level"), the message category (key "l4p_category") and the content of the message (key "message"). If the subroutine returns 1, it will trigger a flush of buffered messages. Shortcut DEVELOPMENT NOTES
"Log::Log4perl::Appender::Buffer" is a composite appender. Unlike other appenders, it doesn't log any messages, it just passes them on to its attached sub-appender. For this reason, it doesn't need a layout (contrary to regular appenders). If it defines none, messages are passed on unaltered. Custom filters are also applied to the composite appender only. They are not applied to the sub-appender. Same applies to appender thresholds. This behaviour might change in the future. COPYRIGHT AND LICENSE
Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess <cpan@goess.org>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.1 2010-02-16 Appender::Buffer(3)
All times are GMT -4. The time now is 05:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy