#!/usr/bin/env python

import os
import sys
import signal

def cb(signame):
    sys.stdout.write("%s\n" % signame)
    sys.stdout.flush()

def addsignalhandler(signame, cb):
    sigval = getattr(signal, signame, None)
    if not sigval:
        return
    def scb(*args):
        cb(signame)
    signal.signal(sigval, scb)

WINDOW_SIGNALS = os.environ.get("XPRA_WINDOW_SIGNALS",
                                "SIGINT,SIGTERM,SIGQUIT,SIGCONT,SIGUSR1,SIGUSR2").split(",")
for x in WINDOW_SIGNALS:
    addsignalhandler(x, cb)
def sig_exit(signame):
    cb(signame)
    sys.exit(1)
addsignalhandler("SIGPIPE", sig_exit)
addsignalhandler("SIGHUP", sig_exit)

sys.stdin.readline()

