Closing a running program from a process

后端 未结 1 1380
终归单人心
终归单人心 2021-01-25 20:12

How can I close a program from a child process? For exanple:

import easygui
import multiprocessing

def func():
    reply=easygui.buttonbox(\"start?\",image=\"F:         


        
相关标签:
1条回答
  • 2021-01-25 21:09

    Your forgot to actually call the function:

    import easygui
    import multiprocessing
    
    def func():
        reply=easygui.buttonbox("start?",image="F:\project\phonber.png",choices=['yes','no'])
        if reply=="yes":
            exit_option()
    
    func()
    
    
    if __name__=='__main__':
        p=multiprocessing.Process(target=func,args=())
        t=p.start()
        while True:
            None
    

    Then, to actually kill a running process there are, of course, many options. The most obvious ones being psutil its kill or terminate method, or os its kill method. Both as shown here.

    0 讨论(0)
提交回复
热议问题