Server IP : 128.199.20.84 / Your IP : 172.71.254.130 Web Server : Apache/2.4.41 (Ubuntu) System : Linux competent-maruti 5.4.0-128-generic #144-Ubuntu SMP Tue Sep 20 11:00:04 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.0.20 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF Directory (0755) : /usr/lib/python3.9/../python3/dist-packages/cloudinit/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
# Copyright (C) 2012 Canonical Ltd. # Copyright (C) 2012 Yahoo! Inc. # # Author: Scott Moser <[email protected]> # Author: Joshua Harlow <[email protected]> # # This file is part of cloud-init. See LICENSE file for license information. import inspect import signal import sys from io import StringIO from cloudinit import log as logging from cloudinit import util from cloudinit import version as vr LOG = logging.getLogger(__name__) BACK_FRAME_TRACE_DEPTH = 3 EXIT_FOR = { signal.SIGINT: ("Cloud-init %(version)s received SIGINT, exiting...", 1), signal.SIGTERM: ("Cloud-init %(version)s received SIGTERM, exiting...", 1), # Can't be caught... # signal.SIGKILL: ('Cloud-init killed, exiting...', 1), signal.SIGABRT: ("Cloud-init %(version)s received SIGABRT, exiting...", 1), } def _pprint_frame(frame, depth, max_depth, contents): if depth > max_depth or not frame: return frame_info = inspect.getframeinfo(frame) prefix = " " * (depth * 2) contents.write("%sFilename: %s\n" % (prefix, frame_info.filename)) contents.write("%sFunction: %s\n" % (prefix, frame_info.function)) contents.write("%sLine number: %s\n" % (prefix, frame_info.lineno)) _pprint_frame(frame.f_back, depth + 1, max_depth, contents) def _handle_exit(signum, frame): (msg, rc) = EXIT_FOR[signum] msg = msg % ({"version": vr.version_string()}) contents = StringIO() contents.write("%s\n" % (msg)) _pprint_frame(frame, 1, BACK_FRAME_TRACE_DEPTH, contents) util.multi_log(contents.getvalue(), console=True, stderr=False, log=LOG) sys.exit(rc) def attach_handlers(): sigs_attached = 0 for signum in EXIT_FOR.keys(): signal.signal(signum, _handle_exit) sigs_attached += len(EXIT_FOR) return sigs_attached # vi: ts=4 expandtab