process and spinning slash
I am trying to fork and exec a child by python. Additionally, I am
attempting
to have a spinning slash while the child is running.
My code is as below:
import sys, os, time
def spin(delay):
pattern=['-','\\','|','/','-','\\','|']
while 1:
for i in pattern:
sys.stdout.write(i + " ")
sys.stdout.flush()
sys.stdout.write("\b\b")
time.sleep(delay)
pid = os.fork()
if pid == 0:
os.execvp("du",("du","-shc","/"))
else:
spin(0.05)
However, the spinner is kept spinning even the child process was ended.
Any idea ? Thanks!
.
Relevant Pages
- Re: Killing a process that takes too long
... You may instead use fork and exec; this lets you use the process-ID to ... kill 'INT', $pid; ... and it does not guarantee that the child ... So we need a way to kill several processes of the process group of the parent, ... (perl.beginners) - Re: SBCL just turned 1.0!
... Lisp implementation means either lazyness or technical incompetence ... "Return any available status information on child processed. ... (multiple-value-bind (pid status) ... ;; Terminate the child process. ... (comp.lang.lisp) - Re: OT: fork(): parent or child should run first?
... >>> called waitpid() on it? ... > it is actually prepared for the pid to be reclaimed. ... child did some work or slept before it exited. ... > active to an inactive array in the signal handler. ... (Linux-Kernel) - Re: Killing a process that takes too long
... and it does not guarantee that the child ... You can test it by placing $$ (process pid) in the output of these two ... So we need a way to kill several processes of the process group of the parent, ... (perl.beginners) - Re: optimize log parsing
... >> Hey Xho, I tried this: ... >> for the constructor is 0 then, assuming you're in the child process, ... >> called after the successful startup of a child in the parent process. ... >> - pid of the process which has been started ... (comp.lang.perl.misc) |
|