mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 17:00:58 +01:00
avoid polling and time delay when waiting for current job to stop
This commit is contained in:
parent
e8aadbb298
commit
de7665b696
1 changed files with 9 additions and 16 deletions
|
@ -103,22 +103,15 @@ def wait_for_active_job():
|
||||||
obj.done = False
|
obj.done = False
|
||||||
|
|
||||||
_give_terminal_to(pgrp) # give the terminal over to the fg process
|
_give_terminal_to(pgrp) # give the terminal over to the fg process
|
||||||
while True:
|
p, s = os.waitpid(obj.pid, os.WUNTRACED)
|
||||||
p, s = os.waitpid(obj.pid, os.WNOHANG | os.WUNTRACED)
|
if os.WIFSTOPPED(s):
|
||||||
if p == obj.pid:
|
obj.done = True
|
||||||
if os.WIFSTOPPED(s):
|
job['bg'] = True
|
||||||
obj.done = True
|
job['status'] = 'stopped'
|
||||||
job['bg'] = True
|
print() # get a newline because ^Z will have been printed
|
||||||
job['status'] = 'stopped'
|
print_one_job(act)
|
||||||
print() # get a newline because ^Z will have been printed
|
elif os.WIFSIGNALED(s):
|
||||||
print_one_job(act)
|
print() # get a newline because ^C will have been printed
|
||||||
break
|
|
||||||
elif os.WIFSIGNALED(s):
|
|
||||||
print() # get a newline because ^C will have been printed
|
|
||||||
break
|
|
||||||
elif os.WIFEXITED(s):
|
|
||||||
break
|
|
||||||
time.sleep(0.1)
|
|
||||||
if obj.poll() is not None:
|
if obj.poll() is not None:
|
||||||
builtins.__xonsh_active_job__ = None
|
builtins.__xonsh_active_job__ = None
|
||||||
_give_terminal_to(_shell_pgrp) # give terminal back to the shell
|
_give_terminal_to(_shell_pgrp) # give terminal back to the shell
|
||||||
|
|
Loading…
Add table
Reference in a new issue