[Linux] process concept related instructions, view process, kill process

insert image description here
1.touch myproc.c
2.ls > Makefile Create and write Makefile
3.vim Makefile
insert image description here
insert image description here
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;
}

insert image description here
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
insert image description here
7. Check the running process

ps ajx | grep 'myproc'

insert image description here
8. You can execute the command to take out the title of the process

ps ajx | head -1 && ps ajx | grep 'myproc'

insert image description here
9. Kill the process kill -9 xxxx
insert image description here
10. man getpid Get the manual of getpid
insert image description here
11. vim myproc.c
insert image description here12. After make, ./myproc runs
insert image description here
13. kill -l Check the process number (kill -9 kill the process)
insert image description here

Guess you like

Origin blog.csdn.net/weixin_47952981/article/details/129593476