Every activity with the server is logged to a specific file..
But when i tail the server side logs, i see it updated after a certain
specified amount of time.
What i am assuming is that the write to the Server side log file is
buffered so it is being updated after the buffer is being filledup.
Assuming i am writing my logs to the '/tmp/abcll.logs' file. I have
specified the complete path of the file here.

My doubt is until the output is written onto the log file, it has to
be stored in a temporary buffer.
Where would that temporary buffer reside in the specific unix host.??

What i am assuming is that temporary buffer is located in '/var/tmp/'
directory.

Please correct me if i am wrong in my conceptual understanding.

So as long as my server program is alive it keeps on creating
temporary buffers in '/var/tmp/' directory.
Simultaneuosly some other programs would also be accesing that /var/
tmp directory.
What if there is 100% occupancy in that /tmp/var directory. and there
is no space to store that
temporary buffer....?

Will my program which is writing to the temporary buffer fail..??

Please correct me if i am wrong in interpreting the usage of '/var/
tmp' directory.

Thanks in advance,
Ravikanth

10-10-2008, 12:17 PM

unix

Re: /var/tmp concept clarification

Ravikanth <rkanth.vvn@gmail.com> writes:[color=blue]
>
> I am running a client server application on UNIX platform.
>
> Every activity with the server is logged to a specific file..
> But when i tail the server side logs, i see it updated after a certain
> specified amount of time. What i am assuming is that the write to
> the Server side log file is buffered so it is being updated after
> the buffer is being filledup.[/color]

This sounds as if you were using stdio-routine to write to this
file. By default stdio-streams 'connected' to regular files are block
buffered, which would match the behaviour you described. Depending on
how you generate the log message, you should probably either

- use the stderr stream, possibly after having redirected
file descriptor 2 to the log file.

- disable buffering for the log output stream (via setvbuf(3)).

- flush this stream (fflush(3)) whenever a message has been
composed completely.

- not use stdio at all, but write (write(2)) completely
formatted log messages to the file descriptor of your
log file.
[color=blue]
> Assuming i am writing my logs to the '/tmp/abcll.logs' file. I have
> specified the complete path of the file here.
>
> My doubt is until the output is written onto the log file, it has to
> be stored in a temporary buffer. Where would that temporary buffer
> reside in the specific unix host.??[/color]

Application memory.
[color=blue]
> What i am assuming is that temporary buffer is located in '/var/tmp/'
> directory.
>
> Please correct me if i am wrong in my conceptual understanding.[/color]

You are. /var/tmp is a directory intended to be used for temporary
files which should not automatically be deleted during system boot
(that's at least the 'Filesystem Hierarchy Standard' definition,
meaning it should be correct for most Linux distributions).