mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-23 04:30:10 +09:00
Add 'wait and cooperative exit' handling for SIGINT
This allows compatible shells to stop script execution when the user sends SIGINT. Only tested on Ubuntu Linux
This commit is contained in:
parent
4fb25ff5a3
commit
981f87b00f
@ -478,7 +478,13 @@ def main(argv=None):
|
|||||||
except SameFileError:
|
except SameFileError:
|
||||||
sys.exit('ERROR: fixed output name but more than one file to download')
|
sys.exit('ERROR: fixed output name but more than one file to download')
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit('\nERROR: Interrupted by user')
|
print('\nERROR: Interrupted by user')
|
||||||
|
# 'wait and cooperative exit' handling of SIGINT
|
||||||
|
# this signals our parent that we exited because of SIGINT
|
||||||
|
# the compatible parent shell can then stop script execution
|
||||||
|
import signal
|
||||||
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
os.kill(os.getpid(), signal.SIGINT)
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['main', 'YoutubeDL', 'gen_extractors', 'list_extractors']
|
__all__ = ['main', 'YoutubeDL', 'gen_extractors', 'list_extractors']
|
||||||
|
Loading…
Reference in New Issue
Block a user