One
The following code is a test of the fork
650) this.width=650; "title=" 3.png "src=" Http://s2.51cto.com/wyfs02/M00/82/FB/wKiom1dnt9_zgSzPAACUlAwxU_o291.png " alt= "Wkiom1dnt9_zgszpaaculawxu_o291.png"/>
The result of the operation is:
650) this.width=650; "title=" 4.png "src=" Http://s4.51cto.com/wyfs02/M01/82/FB/wKiom1dnuBfxhJ9dAAC6tIORnao743.png " alt= "Wkiom1dnubfxhj9daac6tiornao743.png"/>
As you can see, the PID of all processes is 10604 ~ 10611 (Total 8 2 ^ 3)
Modify the loop condition so that the loop executes 5 times,
PID for all processes: 10637 ~ 10668 (Total 32 2 ^ 5)
As you can see, the loop executes n times, the number of processes is: 2 ^ n
Two
File Structure Body:
First position:
Cd/usr/include
Search:
Gerp ' FILE ' stdio.h
There's a whole bunch of searches, but there's a line of code:
typedef struct _IO_FILE FILE;
So next search _io_file:
grep ' _io_file ' *.h
A few lines were searched, with one line:
Libio.h:struct _io_file
Which means the _io_file we're looking for is in libio.h.
So then open libio.h.
Vim Libio.h
Then, search _io_file in the bottom bar mode
:/_io_file
Search a few more times until the definition is searched.
The search definition is as follows:
650) this.width=650; "title=" 5.png "src=" Http://s2.51cto.com/wyfs02/M02/82/FC/wKiom1dnvmWxSoAHAAHiGXqqSrw156.png " alt= "Wkiom1dnvmwxsoahaahigxqqsrw156.png"/>
Three
Let's look at the following code:
650) this.width=650; "title=" 1.png "alt=" Wkiom1dnqwpjashzaacvnftvuh0609.png "src=" http://s5.51cto.com/wyfs02/M02/ 82/fa/wkiom1dnqwpjashzaacvnftvuh0609.png "/>
When the part of sleep (5) of the note is present,
The parent process ends later than the child process, at which point the output is:
650) this.width=650; "title=" 2.png "alt=" Wkiom1dnqzzddbifaaat85mzemy773.png "src=" http://s1.51cto.com/wyfs02/M02/ 82/fa/wkiom1dnqzzddbifaaat85mzemy773.png "/>
It's in line with our expectations.
However, if you want to comment out the line of sleep (5) in my picture,
The parent process ends before the child process.
For a child process, it is executing, and suddenly its parent process is over,
At this time, the child process is called the "orphan process",
Its parent process becomes init (number 1th process)
Linux Learning Notes (fork && FILE && PC)