fork combined with redirection
From: Prakash Prabhu (prakash.prabhu_at_gmail.com)
Date: 01/25/05
- Next message: Rick Ankrum: "Re: USB Flash Drive and Linux"
- Previous message: Thomas D. Shepard: "Re: how to get rid of grub"
- Next in thread: mjt: "Re: fork combined with redirection"
- Reply: mjt: "Re: fork combined with redirection"
- Reply: Laurenz Albe: "Re: fork combined with redirection"
- Reply: moma: "Re: fork combined with redirection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Jan 2005 03:14:35 -0800
Hi ,
I ran the following code with output redirected to a file . I got weird
results ( or is that the
expected output ) ?
#include<stdio.h>
int main()
{
printf("\n Hello ");
if ( fork() == 0 )
{
printf("\n World");
}
return 0;
}
$ gcc -o hello hello.c
$ ./hello > out
$ cat out
Hello
World
Hello
Why is Hello being printed twice ?
- Next message: Rick Ankrum: "Re: USB Flash Drive and Linux"
- Previous message: Thomas D. Shepard: "Re: how to get rid of grub"
- Next in thread: mjt: "Re: fork combined with redirection"
- Reply: mjt: "Re: fork combined with redirection"
- Reply: Laurenz Albe: "Re: fork combined with redirection"
- Reply: moma: "Re: fork combined with redirection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|