Thanks Florin. But my doubt still remains. The child exits after the parent exits. So in this case the child is inherited by init process. I get it till here. But after the child terminates, I get the prompt back and am not able to see it. Am able to do everything as I can do at a prompt because it is the prompt the parent returned? Now when the child exits, will it give the prompt back to me(along with the stack, heap etc copies does the child get the shell too?). If it does I don't see it. Finally, as the child has been inherited by init, what happens after the child exits? Am confused. Thanks. Gowri. -----Original Message----- From: Florin Malita [mailto:mali@go.ro] Sent: Wednesday, March 03, 2004 6:39 PM To: kernelnewbies@nl.linux.org Cc: Gowri Ramasubramanian Subject: RE: some trivial problem with fork Your parent process exits before the child, so you get the prompt back. Then the child prints the message/flushes buffers/exits so you get the message showing up after the prompt. Add a wait/waitpid call before the parent exits to make it wait for the child result. Florin -----Original Message----- From: kernelnewbies-bounce@nl.linux.org [mailto:kernelnewbies-bounce@nl.linux.org] On Behalf Of Gowri Ramasubramanian Sent: Wednesday, March 03, 2004 6:40 AM To: kernelnewbies@nl.linux.org Subject: some trivial problem with fork Hi All, I know this is very trivial. Might be am missing something out. Have attached the code When I run the code I get to see "hello" on stdout and then get the prompt but am not able to see it. What i mean is say the prompt is prompt> prompt>./a.out prompt>hello I get a prompt and then see hello and I don't see the prompt after hello. Actually what I expect is prompt>./a.out helloprompt> But if I type "ls" or anything after hello it shows the output. So it means that the prompt is there. What I mean is prompt>./a.out prompt>helloecho hi hi prompt> Hope I have been clear. Thanks. Gowri. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/