1、創建進程
code:
結果:
in the parent
in the child
2、父子進程 對打開文件的處理
notes:子進程將複製父進程的數據段、BSS、代碼段、堆空間、棧空間和文件描述符
對於文件描述符關聯的內核文件表項,則採用共享的方式(父子進程共享文件)
codes:
結果:
Helloworld this is Jason
3、在進程中運行新的代碼
該進程代碼段、數據段 等等完全由新程序代替
code:
結果:
father ok
root@ubuntu:/code/chap6# total 104
drwxr-xr-x 2 root root 4096 2010-11-15 16:05 chap3
drwxr-xr-x 2 root root 4096 2010-11-16 21:14 chap4
drwxr-xr-x 2 root root 4096 2010-11-17 20:50 chap5
drwxr-xr-x 2 root root 4096 2010-11-22 17:31 chap6
drwxr-xr-x 2 root root 4096 2010-11-22 15:57 chap8
-rw-r--r-- 1 root root 70 2010-11-07 16:34 fac.c
-rw-r--r-- 1 root root 1352 2010-11-07 16:41 fac.o
-rw-r--r-- 1 root root 11 2010-11-07 15:38 hello2.c
-rw-r--r-- 1 root root 75 2010-11-07 15:45 hello.c
-rw-r--r-- 1 root root 243 2010-11-16 19:49 main.c
-rw-r--r-- 1 root root 243 2010-11-07 16:40 main.c~
-rw-r--r-- 1 root root 39255 2010-11-07 17:07 main.i
-rw-r--r-- 1 root root 1768 2010-11-07 16:40 main.o
-rwxr-xr-x 1 root root 8494 2010-11-07 16:42 run
drwxr-xr-x 2 root root 4096 2010-11-07 17:41 testSpot