Re: [PLUG] Weird Output of a C program in Linux

2007-07-18 Thread Ashutosh Adkar
On 7/18/07, yogesh tillu [EMAIL PROTECTED] wrote: Aditya Godbole [EMAIL PROTECTED] wrote: On 7/17/07, Pranav Peshwe wrote: IMHO, it does send the data to the buffer. Due to the fork, the new task(child) gets a copy of the buffer (which already contains the 'Hello World!' string).

Re: [PLUG] Weird Output of a C program in Linux

2007-07-18 Thread Aditya Godbole
On 7/18/07, yogesh tillu [EMAIL PROTECTED] wrote: Yeah, thats right. The buffer is filled but not flushed. After the fork, the entire address space (and hence the buffer) gets replicated * But I think currently copy on write approach is used for the *implementation of the fork .So entire address

Re: [PLUG] Weird Output of a C program in Linux

2007-07-17 Thread Devendra Laulkar
Hi, On 7/17/07, Ashutosh Adkar [EMAIL PROTECTED] wrote: int main () { printf (Hello World!); if (fork == 0) printf (I'm the child!\n); else printf (I'm the parent!\n); } The output of the above program is : Hello World!I'm the child! Hello World!I'm the parent! How did you get

Re: [PLUG] Weird Output of a C program in Linux

2007-07-17 Thread Pranav Peshwe
On 7/17/07, Pramod Sonar [EMAIL PROTECTED] wrote: Hi Ashu you are right ! Hello world should be print only ones! but it's printing twice as when printf executes it does not send data to output buffer. IMHO, it does send the data to the buffer. Due to the fork, the new task(child) gets a

Re: [PLUG] Weird Output of a C program in Linux

2007-07-17 Thread Aditya Godbole
On 7/17/07, Pranav Peshwe [EMAIL PROTECTED] wrote: IMHO, it does send the data to the buffer. Due to the fork, the new task(child) gets a copy of the buffer (which already contains the 'Hello World!' string). This(fork()) is where the duplication occurs. Further printfs in the two tasks lead