01-07-2007
Output to a tty is line buffered so the /n causes a flush. In this case, no data remains buffered and you get 4 copies of an empty buffer. Remove the /n and the data stays in the buffer. The buffer (and data) is then quadruplicated and all 4 processes flush their buffers at program exit.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hey guys,
I'm given this bit of code, but, I'm having some problems executing it with the functions I've defined so far. I'm suppose to define the funtions "parse" and "execute." Parse splits the command in buf into individual arguments. It strips whitespace, replacing those it finds with NULLS... (3 Replies)
Discussion started by: richardspence2
3 Replies
2. Programming
Hello!
First of all, sorry for my English, I'm not a native English speaker.
I know, that printf() function uses write() function. "man cancellation" says that write() function is a cancellation point. But when I call pthread_cancel() for my thread, which calls printf() in infinite cycle, it... (4 Replies)
Discussion started by: prankster
4 Replies
3. UNIX for Advanced & Expert Users
I am trying to figure out why when i have the following code
int main( { printf("0\n"); fork(); printf("1\n"); exit(0);}
and type in the shell
a.out | cat
the output of this program is
0
1
0
1
instead of
0
1
1
does anyone know? (3 Replies)
Discussion started by: Phantom12345
3 Replies
4. Programming
i'm tring to make 2 processes each read from the same file but only one of them read the file.
FILE * fileptr1;
fileptr1 = fopen("file1.txt","rt");
pid2=fork();
while(1)
{
fscanf(fileptr1,"%s",temp1);
if(feof(fileptr1)==0)
{
printf("%i",getpid()); //id of current process ... (6 Replies)
Discussion started by: ddx08
6 Replies
5. Shell Programming and Scripting
can you take input from another command and do printf?
such as
awk '{print $2,$1}' | sort -k1,1 -k2,2 | printf "%-10s,%15s"
this does not work.. but there must be a way.. please help me..
thank you. (3 Replies)
Discussion started by: hankooknara
3 Replies
6. UNIX for Dummies Questions & Answers
Hi,
Does anyone know a easy way to printf $3,$4, ... all the way to the last field in the file? I will need to modify $1 and $2 and then printf modified $1 and $2 and the rest of the fields(which are not changed).
I know I can use NF as the total number of field.
Do I use a for next statement to... (4 Replies)
Discussion started by: whatisthis
4 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I am using below awk code to convert a csv file data into fixed file format.
awk 'BEGIN { FS = ","
fmt = "%10s%010d%10s%d%1d\n" }
NR>1 { printf fmt, $1, $2, $3, $4*100, $5 }' /data/mydata.csv > /data/fixed.dat
Data in mydata.csv
================... (1 Reply)
Discussion started by: kbmkris
1 Replies
8. Shell Programming and Scripting
Hi,
I am using below awk code to convert a csv file data into fixed file format.
awk 'BEGIN { FS = ","
fmt = "%10s%010d%10s%d%1d\n" }
NR>1 { printf fmt, $1, $2, $3, $4*100, $5 }' /data/mydata.csv > /data/fixed.dat
Data in mydata.csv
================... (2 Replies)
Discussion started by: kbmkris
2 Replies
9. Shell Programming and Scripting
Hi Experts,
Quick question:
I am trying to get the output with decimal and floating point but not working:
echo "20.03" | awk '{printf "%03d.2f\n" , $0 }'
020.2f
How to get the output as :
020.03
Thank you. (4 Replies)
Discussion started by: rveri
4 Replies
10. Shell Programming and Scripting
all,
i've been reading to try and get an abstract idea of the process effeciency of commands , sed, bash, perl, awk, find, grep, etc
which processes will spawn?, fork?, launch subshell?, etc and under what conditions?
how do you know which commands have the faster and better stdio... (2 Replies)
Discussion started by: f77hack
2 Replies
LEARN ABOUT OSX
gldrawbuffer
GLDRAWBUFFER(3G) GLDRAWBUFFER(3G)
NAME
glDrawBuffer - specify which color buffers are to be drawn into
C SPECIFICATION
void glDrawBuffer( GLenum mode )
PARAMETERS
mode Specifies up to four color buffers to be drawn into. Symbolic constants GL_NONE, GL_FRONT_LEFT, GL_FRONT_RIGHT, GL_BACK_LEFT,
GL_BACK_RIGHT, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, GL_FRONT_AND_BACK, and GL_AUXi, where i is between 0 and
``GL_AUX_BUFFERS'' -1, are accepted (GL_AUX_BUFFERS is not the upper limit; use glGet to query the number of available aux buffers.)
The initial value is GL_FRONT for single-buffered contexts, and GL_BACK for double-buffered contexts.
DESCRIPTION
When colors are written to the frame buffer, they are written into the color buffers specified by glDrawBuffer. The specifications are as
follows:
GL_NONE No color buffers are written.
GL_FRONT_LEFT Only the front left color buffer is written.
GL_FRONT_RIGHT Only the front right color buffer is written.
GL_BACK_LEFT Only the back left color buffer is written.
GL_BACK_RIGHT Only the back right color buffer is written.
GL_FRONT Only the front left and front right color buffers are written. If there is no front right color buffer, only the
front left color buffer is written.
GL_BACK Only the back left and back right color buffers are written. If there is no back right color buffer, only the
back left color buffer is written.
GL_LEFT Only the front left and back left color buffers are written. If there is no back left color buffer, only the
front left color buffer is written.
GL_RIGHT Only the front right and back right color buffers are written. If there is no back right color buffer, only the
front right color buffer is written.
GL_FRONT_AND_BACK All the front and back color buffers (front left, front right, back left, back right) are written. If there are
no back color buffers, only the front left and front right color buffers are written. If there are no right color
buffers, only the front left and back left color buffers are written. If there are no right or back color buf-
fers, only the front left color buffer is written.
GL_AUXi Only auxiliary color buffer i is written.
If more than one color buffer is selected for drawing, then blending or logical operations are computed and applied independently for each
color buffer and can produce different results in each buffer.
Monoscopic contexts include only left buffers, and stereoscopic contexts include both left and right buffers. Likewise, single-buffered
contexts include only front buffers, and double-buffered contexts include both front and back buffers. The context is selected at GL ini-
tialization.
NOTES
It is always the case that GL_AUXi = GL_AUX0 + i.
ERRORS
GL_INVALID_ENUM is generated if mode is not an accepted value.
GL_INVALID_OPERATION is generated if none of the buffers indicated by mode exists.
GL_INVALID_OPERATION is generated if glDrawBuffer is executed between the execution of glBegin and the corresponding execution of glEnd.
ASSOCIATED GETS
glGet with argument GL_DRAW_BUFFER
glGet with argument GL_AUX_BUFFERS
SEE ALSO
glBlendFunc, glColorMask, glIndexMask, glLogicOp, glReadBuffer
GLDRAWBUFFER(3G)