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