Ask a process question ~~~~~~~~~~ -- Linux general technology-Linux programming and kernel information. The following is a detailed description. I am eager to ask a question when I post for the first time. I can't figure it out for a long time ~~~~~
Int main ()
{
Printf ("main % d \ n", getpid (); // print Statement 1
Pid_t I = fork ();
Printf ("main_2% d \ n", getpid (); // print Statement 2
If (I = 0)
Printf ("I % d, I % d \ n", I, getpid (); // print Statement 3
Else
Printf ("I % d, I % d \ n", I, getpid (); // print Statement 5
}
Let's take a look at the above program, which is to create a new process in main () and test the process in which each statement is located. The output result is as follows:
I have no doubt about the 4th, and sentences in the output results. Why do I call the previous print Statement 2: 0wl; l1 when entering the parent process space ???
I'm a new student. It's silly. Please give me some details. Thank you ~~~~~~~~~~ (O): tx
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service