Caleb Rouleau | 6844df15 | 2019-09-11 01:11:59 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2019 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | """Script for use in test_env unittests.""" |
| 7 | |
Chris McDonald | c3e0f26b | 2020-06-04 02:15:14 | [diff] [blame] | 8 | from __future__ import print_function |
Caleb Rouleau | 6844df15 | 2019-09-11 01:11:59 | [diff] [blame] | 9 | import signal |
| 10 | import sys |
| 11 | import time |
| 12 | |
| 13 | |
Chris McDonald | c3e0f26b | 2020-06-04 02:15:14 | [diff] [blame] | 14 | def print_signal(sig, *_args): |
| 15 | print('Signal :{}'.format(sig)) |
Caleb Rouleau | 6844df15 | 2019-09-11 01:11:59 | [diff] [blame] | 16 | |
| 17 | |
| 18 | if __name__ == '__main__': |
| 19 | signal.signal(signal.SIGTERM, print_signal) |
| 20 | signal.signal(signal.SIGINT, print_signal) |
| 21 | if sys.platform == 'win32': |
| 22 | signal.signal(signal.SIGBREAK, print_signal) |
| 23 | time.sleep(2) # gives process time to receive signal. |