"benz" <[EMAIL PROTECTED]> wrote
>I have rewrited my code as follow, but it still not working.
>
> import os, sys
>
>
> pid = os.fork()
>
> if pid == 0:
> os.execvp("du",("du","-shc","/usr/share"))
> else:
> while 1:
>try:
> os.kill(pid,0)
> sys.stdout.write('running')
> sys.s
I have rewrited my code as follow, but it still not working.
import os, sys
pid = os.fork()
if pid == 0:
os.execvp("du",("du","-shc","/usr/share"))
else:
while 1:
try:
os.kill(pid,0)
sys.stdout.write('running')
sys.stdout.flush()
sys.stdout.write('\b\b\b\b\b\b\b'
[EMAIL PROTECTED] (Alex Martelli) writes:
> Have the spin function accept the pid argument and exit the loop if said
> pid has terminated; to check the latter, e.g., os.kill(pid, 0) -- this
> will raise an OSError if no process with that pid exists, so you can use
> a try/except OSError: to catch
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
>
> > Have the spin function accept the pid argument and exit the loop if said
> > pid has terminated; to check the latter, e.g., os.kill(pid, 0) -- this
> > will raise an OSError if no process with that pid exists, so you can use
>
Alex Martelli wrote:
> Have the spin function accept the pid argument and exit the loop if said
> pid has terminated; to check the latter, e.g., os.kill(pid, 0) -- this
> will raise an OSError if no process with that pid exists, so you can use
> a try/except OSError: to catch that and break as app
benz <[EMAIL PROTECTED]> wrote:
...
> 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 =
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 + "