Results 1 to 3 of 3
Hi all
I am just gaining some understanding the fork system by the following simple program.
#include<unistd.h>
#include<stdio.h>
int main()
{
pid_t pid;
printf("Inside the Parent Process \n");
if((pid = ...
- 01-27-2010 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 4
[SOLVED] Standard I/O redirection in linux
Hi all
I am just gaining some understanding the fork system by the following simple program.
#include<unistd.h>
#include<stdio.h>
int main()
{
pid_t pid;
printf("Inside the Parent Process \n");
if((pid = fork())<0 )
printf("Oooops Error Occured in forking \n");
else if (pid ==0)
printf("Inside the child process and the process id is %d \n", getpid());
else
printf( "inside the parent process and the process id is %d \n",getpid());
}/*end of main */
when i run the program in terminal i get the expected output, but when i redirect the output to a file the file does not have the printf information of the child process.
my question is does linux perform standard I/O redirection for only the parent process and not the child process? or am i missing something.
can someone clarify!!
thanks
- 01-27-2010 #2Just Joined!
- Join Date
- Nov 2009
- Posts
- 4
- 01-27-2010 #3
Out of curiosity, what was your solution? I'm looking at it and can't would be interested.
DISTRO=Arch
Registered Linux User #388732



