mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
Merge pull request #2221 from xonsh/give-term-to-none
fixes OSError: [Errno 22] Invalid argument
This commit is contained in:
commit
25c105c8f2
2 changed files with 27 additions and 3 deletions
14
news/give-term-to-none.rst
Normal file
14
news/give-term-to-none.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
**Added:** None
|
||||
|
||||
**Changed:** None
|
||||
|
||||
**Deprecated:** None
|
||||
|
||||
**Removed:** None
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* Fixed a potential "OSError: [Errno 22] Invalid argument" to increase job
|
||||
control stability.
|
||||
|
||||
**Security:** None
|
|
@ -135,9 +135,19 @@ else:
|
|||
def give_terminal_to(pgid):
|
||||
oldmask = signal.pthread_sigmask(signal.SIG_BLOCK,
|
||||
_block_when_giving)
|
||||
os.tcsetpgrp(FD_STDERR, pgid)
|
||||
signal.pthread_sigmask(signal.SIG_SETMASK, oldmask)
|
||||
return True
|
||||
try:
|
||||
os.tcsetpgrp(FD_STDERR, pgid)
|
||||
return True
|
||||
except OSError as e:
|
||||
if e.errno == 22: # [Errno 22] Invalid argument
|
||||
# there are cases that all the processes of pgid have
|
||||
# finished, then we don't need to do anything here, see
|
||||
# issue #2220
|
||||
return False
|
||||
else:
|
||||
raise
|
||||
finally:
|
||||
signal.pthread_sigmask(signal.SIG_SETMASK, oldmask)
|
||||
|
||||
def wait_for_active_job(last_task=None, backgrounded=False):
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue