欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Process&Program

程序员文章站 2022-06-19 10:59:25
...

Abstract: Have you ever been curious about that, When you run a program, your task management will appear maybe more than one processes. Why this way?

Process&Program

First: When you run a program, may it link more than one execution files.

For example, if you double click QQPCTray.exe, you will see below the pic on task management, including two services processes and the other three.

Process&Program

This quite a lot of fun, that you try to end this task, the system will tell you low Authority. I’m a newbie on OS and do these things. The only way that I know is the right-click the icon and exit QQ管家. After that, I found 电脑管家 and 小火箭 processes dismissed and Disk using became 100%.

What’s the QQ管家 and 小火箭’s relationship they are? I guess QQ管家 is the parent process.

Let’s do some tests, see what’s the situation that QQ管家 belongs to.

Using python open another python file

process.py

import os

if __name__ == '__main__':
    os.system('python process2.py')
    print("Main Process ID:"+str(os.getpid()))
    input()
process2.py

import os

print("process2 ID: "+str(os.getpid()))

When you run process.py, cmd will print two PID.

import another python

process.py

import os
import process2

if __name__ == '__main__':
    print("Main Process ID:"+str(os.getpid()))
    input()
process2.py

import os

print("process2 ID: "+str(os.getpid()))

You will find only print a PID.

相关标签: Operating System

推荐阅读