RE: some trivial problem with fork

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux