# Catch SIGHUP from agi in Python?

**URL:** <https://community.asterisk.org/t/catch-sighup-from-agi-in-python/70233>\
**Category:** Asterisk Support\
**Created:** [March 31, 2017, 1:04pm UTC](https://community.asterisk.org/t/catch-sighup-from-agi-in-python/70233 "2017-03-31T13:04:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phonefxg](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/phonefxg/32/2094_2.png) [@phonefxg](https://community.asterisk.org/u/phonefxg)\
**Post date:** [March 31, 2017, 1:04pm UTC](https://community.asterisk.org/t/catch-sighup-from-agi-in-python/70233/1 "2017-03-31T13:04:07Z")

</div>

Hi,

Has anyone successfully catch a SIGHUP signal when running a python AGI?  
I’d like to execute some actions when a user enters the AGI and hangup.  
I’m using pyst2. Should I be able to to see the SIGHUP sent to my application when AGI set debug is on?

Part of my Python code to detect hangup  
import signal  
signal.signal(signal.SIGHUP, signal\_handler)

def signal\_handler(signal, frame):  
print (‘User hangup’)  
sys.exit(0)

I’m using asterisk 14.2

---

<div class="post-metadata">

**Author:** ![phonefxg](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/phonefxg/32/2094_2.png) [@phonefxg](https://community.asterisk.org/u/phonefxg)\
**Post date:** [April 5, 2017, 8:25pm UTC](https://community.asterisk.org/t/catch-sighup-from-agi-in-python/70233/2 "2017-04-05T20:25:55Z")

</div>

The thing that puzzles me, is that once in a while I do catch the SIGHUP event and other time nothing.
