Start background process/daemon from CGI script

后端 未结 10 1179
北恋
北恋 2020-12-10 02:02

I\'m trying to launch a background process from a CGI scripts. Basically, when a form is submitted the CGI script will indicate to the user that his or her request is being

10条回答
  •  青春惊慌失措
    2020-12-10 02:36

    I needed to break the stdout as well as the stderr like this:

    sys.stdout.flush()
    os.close(sys.stdout.fileno()) # Break web pipe
    sys.sterr.flush()
    os.close(sys.stderr.fileno()) # Break web pipe
    if os.fork(): # Get out parent process
       sys.exit()
    #background processing follows here
    

提交回复
热议问题