1.touch myproc.c
2.ls > Makefile Create and write Makefile
3.vim Makefile
5. Write basic Makefile: vim Makefile
myproc:myproc.c
gcc -o myproc myproc.c
.PHONY:clean
clean:
rm -f myproc
4. Write myprocess.c file: vim myproc.c
#include<stdio.h>
#include<unistd,h>
int main()
{
while(1)
{
printf("我是一个进程!\n");
sleep(1);
}
return 0;
}
5. After make, the running file myproc will appear (not a process, but a binary file running on the disk)
6.../myproc, it will become a process
7. Check the running process
ps ajx | grep 'myproc'
8. You can execute the command to take out the title of the process
ps ajx | head -1 && ps ajx | grep 'myproc'
9. Kill the process kill -9 xxxx
10. man getpid Get the manual of getpid
11. vim myproc.c
12. After make, ./myproc runs
13. kill -l Check the process number (kill -9 kill the process)