Input across fork() and exec() calls

Input across fork() and exec() calls

Post by Saripalli Ramakrish » Mon, 08 Jun 1992 14:38:06



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).

 
 
 

1. Are signal masks propagated across exec calls ?

Unix Question:

Is the signal mask resulting from a sighold(), sigrelse(), or sigsetmask()
propagated across fork(), exec() calls ?

I say YES it's propagated across the fork(), but I'm not sure about
the exec() but I am guessing NO.  Is this correct ?

Thanx in advance,  

--

University of Florida        UUCP:      ..!uflorida!bikini.cis.ufl.edu!kcw

"C Code.  C code run.  Run, code, run... PLEASE!!!"  -- Barbara Toungue

2. PPP Server

3. General Fork()/Exec()/System() Call Question

4. X equivalent of "write".

5. exec & fork in a system call

6. Simple (?) 'named' question

7. Fork and Exec system calls

8. Terminal defaults?

9. exec & fork in a system call

10. Efficiency: fork() w/ shared libraries vs. fork()/exec()

11. fork call without using function fork()

12. Bash calls TCL, TCL calls Bash, 2nd Bash never reads input

13. What's the difference between in Exec and Exec exec ...