Hi,
I would like to know if scanf() and other I/O calls(including open()..)
work across fork() and exec().
For example if I have in the parent process :-
.....
fgets(str,9,stdin) /*str declared*/
....
and the child process :-
.....
scanf("%s",str); /*str declared*/
....
can both the parent and the child get the same input into their
corresponding date space?.
The child process's text is different from the parent process
(actually exec()..ed process of the child process forked from parent)
Since I am exec() the child process after forking from the parent
and overwriting the text region of the child process,they do not
share the same file identifiers for the input.
I tried this and it does not work.One of the processes is stealing
the input before the other also reads it.I know this happens
when two processes share the same text space and share the same
file identifiers but does this happen even when the text space is
different?.
I know that this happens only with file identifier 0.
Can anyone tell me if there is a solution to this problem of two
mutually related processes trying to read from the same terminal
and both of them not able to read the same?.
Thanks a lot(i am posting from a friend's account).