進程和程序的區(qū)別:
進程是動態(tài)的,程序是靜態(tài)的
一、進程的創(chuàng)建(fork()函數(shù))

int main()
{
pid_t pid;
pid=fork();
if(pid>0)
{
printf("this is father,pid is:%dn",getpid());
}
else if(pid==0)
{
printf("this is son,pid is :%dn",getpid());
}
// printf("pid is :%d,current pid is:%dn",pid,getpid());
return 0;
}
~
結(jié)果:


結(jié)果:



二、進程退出



三、exec族函數(shù)的用法
用perror()的方式打印錯誤碼信息
//文件execl.c
#include ??stdio.h???>
#include ??stdlib.h???>
#include ??unistd.h???>
//函數(shù)原型:int execl(const char *path, const char *arg, ...);
int main(void)
{
printf("before execln");
if(execl("./bin/echoarg","echoarg","abc",NULL) == -1)
{
printf("execl failed!n");
perror("why");
}
printf("after execln");
return 0;
}

四、system系統(tǒng)函數(shù)
-
Linux
+關(guān)注
關(guān)注
88文章
11760瀏覽量
219032 -
進程
+關(guān)注
關(guān)注
0文章
211瀏覽量
14536
發(fā)布評論請先 登錄
Linux進程的睡眠和喚醒
Linux下的進程結(jié)構(gòu)
淺談多進程多線程的選擇
Linux 2.6進程調(diào)度
LINUX 進程源代碼分析
Linux進程管理:什么是進程?進程的生命周期
Linux進程調(diào)度時機概念分析
Linux進程的概念說明
Linux進程權(quán)限的分析說明
你們知道Linux的進程是怎樣創(chuàng)建的嗎
淺談Linux的進程
評論