| Navigation:First_Community->Software->Linux development | Goto:New Topic•Setting•Search | |
MegaEntry - Social networking and discussion site!
fork()及signal经常运用在daemon守护神这一类常驻程式,另外像a4c.tty/yact/chdrv这些中文终端机程式也有用到,一般如Mozilla/Apache/Squid等大程式几乎都一定会用到。 -------------------------------------------------------------------------程序分歧fork() fork()会产生一个与父程序相同的子程序,唯一不同之处在於其process id(pid)。 如果我们要撰写守护神程式,或是例如网路伺服器,需要多个行程来同时提供多个连线,可以利用fork()来产生多个相同的行程。MegaEntry - Social networking and discussion site!
函数宣告 pid_t fork(void); pid_t vfork(void); 返回值: -1 : 失败。 0 : 子程序。MegaEntry - Social networking and discussion site!
>0 : 将子程序的process id传回给父程序。 在Linux下fork()及vfork()是相同的东西。