1、首先在vim环境下编写代码
sw@ubuntu:~$ vim fork.c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(void) {
int i;
for(i = 0; i < 2; i++) {
fork();
printf("-");
}
wait (NULL);
wait(NULL);
return 0;
}
在vim编辑状态(i)下输入这段代码
ESC退出插入模式
:wq 保存并退出
2、查看进程 pstree
sw@ubuntu:~$ pstree
sw@ubuntu:~$ ps -ef | more