Compare commits

...

2 Commits

Author SHA1 Message Date
Hendrik
3fef7a4fe2
Merge 981f87b00fe464fe284055b541a715a4aca1d60d into da7223d4aa42ff9fc680b0951d043dd03cec2d30 2025-03-22 07:14:17 +08:00
h3ndr1k
981f87b00f 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
2021-04-12 12:54:56 +02:00

View File

@ -480,7 +480,13 @@ def main(argv=None):
except SameFileError:
sys.exit('ERROR: fixed output name but more than one file to download')
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']