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
|
||||
|
||||
_give_terminal_to(pgrp) # give the terminal over to the fg process
|
||||
while True:
|
||||
p, s = os.waitpid(obj.pid, os.WNOHANG | os.WUNTRACED)
|
||||
if p == obj.pid:
|
||||
p, s = os.waitpid(obj.pid, os.WUNTRACED)
|
||||
if os.WIFSTOPPED(s):
|
||||
obj.done = True
|
||||
job['bg'] = True
|
||||
job['status'] = 'stopped'
|
||||
print() # get a newline because ^Z will have been printed
|
||||
print_one_job(act)
|
||||
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:
|
||||
builtins.__xonsh_active_job__ = None
|
||||
_give_terminal_to(_shell_pgrp) # give terminal back to the shell
|
||||
|
|
Loading…
Add table
Reference in a new issue