def hup_hook(signal_or_callable=signal.SIGTERM, verbose=False):
<EOL>def handle_hup(signum, frame):<EOL><INDENT>changed = modified()<EOL>if changed:<EOL><INDENT>if callable(signal_or_callable):<EOL><INDENT>func = signal_or_callable<EOL>args = (changed,)<EOL>op = '<STR_LIT>'<EOL>try:<EOL><INDENT>name = signal_or_callable.__name__<EOL><DEDENT>except Exception:<EOL><INDENT>name = str(signal_or_callable)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(signal_or_callable, int):<EOL><INDENT>name = str(signal_or_callable)<EOL>signum = signal_or_callable<EOL>if verbose:<EOL><INDENT>for item in dir(signal):<EOL><INDENT>if item.startswith('<STR_LIT>') and getattr(signal, item) == signal_or_callable:<EOL><INDENT>name = item<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>name = signal_or_callable if signal_or_callable.startswith('<STR_LIT>') else '<STR_LIT>' + signal_or_callable<EOL>signum = getattr(signal, name)<EOL><DEDENT>func = os.kill<EOL>args = (os.getpid(), signum)<EOL>op = '<STR_LIT>'<EOL><DEDENT>if verbose:<EOL><INDENT>more = '<STR_LIT>'.format(len(changed)) if len(changed) > <NUM_LIT:1> else '<STR_LIT>'<EOL>message = '<STR_LIT>'.format(op, name, changed[<NUM_LIT:0>], more)<EOL>if callable(verbose):<EOL><INDENT>verbose(message)<EOL><DEDENT>else:<EOL><INDENT>print(message)<EOL><DEDENT><DEDENT>func(*args)<EOL><DEDENT><DEDENT>files()<EOL>signal.signal(signal.SIGHUP, handle_hup)<EOL>signal.siginterrupt(signal.SIGHUP, False)<EOL>
Register a signal handler for `signal.SIGHUP` that checks for modified
files and only acts if at least one modified file is found.

@type signal_or_callable: str, int or callable
@param signal_or_callable: You can pass either a signal or a callable.
    The signal can be specified by name or number. If specifying by name,
    the 'SIG' portion is optional. For example, valid values for SIGINT
    include 'INT', 'SIGINT' and `signal.SIGINT`.

    Alternatively, you can pass a callable that will be called with the list
    of changed files. So the call signature should be `func(list)`. The return
    value of the callable is ignored.
@type verbose: bool or callable
@param verbose: Defaults to False. True indicates that a message should be
    printed. You can also pass a callable such as log.info.