Re: process and spinning slash

2005-10-31 Thread Fredrik Lundh
"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

Re: process and spinning slash

2005-10-31 Thread benz
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'

Re: process and spinning slash

2005-10-30 Thread Thomas Bellman
[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

Re: process and spinning slash

2005-10-30 Thread Alex Martelli
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 >

Re: process and spinning slash

2005-10-30 Thread Fredrik Lundh
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

Re: process and spinning slash

2005-10-30 Thread Alex Martelli
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 =

process and spinning slash

2005-10-30 Thread benz
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 + "