[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: fork or printf problem
Sumit Rangawala forced the electrons to say:
> One thing i still couldn't understand is that how printf distinguish
> between a terminal and a file.
The stdio code for printf might have something like:
char buffer[BUFSIZ];
if (isatty (fileno (stdout)) {
setvbuf (stdout, buffer, _IOLBUF, sizeof buffer);
} else {
setvbuf (stdout, buffer, _IOFBUF, sizeof buffer);
}
/* Process the arguments to printf */
All the functions mentioned above have man pages. Read them.
> for it everything it has to do is to write to a file pointer ( fp = 1 )
The file pointer fp != 1. It is fileno (fp) == 1.
> How then the buffering changes with the type of file pointed by file
> pointer 1.
man isatty
Binand