vim操作结果问题

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
zhangna
帖子: 1
注册时间: 2017-01-10 15:48

vim操作结果问题

#1

帖子 zhangna » 2017-01-10 16:03

创建zh1.c文件如下:
#include<sys/types.h>
#include<signal.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
void handler(int signo)
{printf("this is child process,pid=%d ,parent id=%d \n",getpid(),getppid());}
int main()
{int pid;
pid=fork();
if(pid<0)
{perror("fork error");}
else if(pid==0)
{signal(SIGUSR1,handler);
pause();
printf("child process exit\n");
exit(0);}
else
{int status;
printf("this is parent process,pid=%d,parent id=%d \n",getpid(),getppid());
printf("waiting for child process exit\n");;
kill(pid,SIGUSR1);
wait(&status);
printf("the child process exit,the return status is 0x%x",status);
pause();}
return 0;
}
执行如下命令
[root@localhost~]#gcc zh1.c -o zh1
[root@localhost~]#./zh1
结果为:
this is parent process,pid=32756,parent id=22845
waiting for child process exit
但是没有回到[root@localhost~]#模式,这是为什么?
cao627
帖子: 992
注册时间: 2007-12-05 10:57
系统: ubuntu14.04
来自: 金山

Re: vim操作结果问题

#2

帖子 cao627 » 2017-01-10 19:54

pause函数令进程暂停了。
回复