As per the bash reference, we can give a non-blocking command by ending it with an ampersand(&) character. However, when I try the below command its not working:
python -m SimpleHTTPServer 8080&
The reason I intend to do so is that I want to start the built-in python webserver as part of another larger program which is also written in python. Can you plz advice how do I issue this command in a non-blocking/daemon mode? I even tried to execute this command using "subprocess.Popen()" in python which is also supposed to create a non-blocking process, but even that is not working:-(..
EDIT: Here is the portion of my python code that starts the webserver (Adding 'nohup' seems to do the trick):
pid_webserver = execute("nohup python -m SimpleHTTPServer 8080 &",wait=False,shellexec= True) #pid_webserver = execute("python -m SimpleHTTPServer 8080 &",wait=False,shellexec= True) def execute(command,errorstring='', wait = True, shellexec = True): try: print 'command=' + command p=subprocess.Popen("gksu '" + command + "'", shell=shellexec,stdout=subprocess.PIPE,stderr=subprocess.PIPE) if wait: p.wait() result=get_stdout(p) return result else: print 'not waiting' return p except subprocess.CalledProcessError as e: print 'error occured:' + errorstring return errorstring