import multiprocessing
import subprocess
import time
import os
def worker(interval):
n = 40
os.popen("python3 test3.py")
while n > 0:
print("The time is {0}".format(time.ctime()))
time.sleep(interval)
n -= 1
if __name__ == "__main__":
# p = subprocess.Popen("python3 test3.py", shell=True, start_new_session=True)
p = multiprocessing.Process(target = worker, args = (3,))
print ("p.pid:", p.pid)
print ("p.name:", p.name)
print ("p.is_alive:", p.is_alive())
p.start()
print("subprocess group is", os.getpgid(p.pid))
os.setpgid(p.pid, p.pid)
print("new subprocess group is", os.getpgid(p.pid))
while True:
time.sleep(1)
12-13
1226
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)