473,412 Members | 5,361 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Repost: Can't sys.exit() from SIGTERM handler?



I have a python program (snippet below) which does not want to seem to die
when I issue a sys.exit() inside the SIGTERM handler. The output below is
generated as the result of sending several SIGTERM signals to the process,
as a result of seeing that it had not died.

I don't think this is relevant, but the application has fork()ed a child
process (cdparanoia). The only thing I can think of is that somehow, there
is an exception occuring inside sys.exit(), otherwise why am I not seeing
the "Did not sys.exit()!?" output? Could it be that exit() is returning but
that the output fd's are already closed?

Verrry strange...and therefore I'm sure I'm making a brain dead mistake.

Thanks in advance,
A.

--------------------------------------------------------------------------

****SIGTERM*****
****SIGTERM*****

...
****SIGCHILD*****
Ripper output status code: (4314, 15)
4320 /root/postprocess /var/music/ripper/8707620b

****SIGCHILD*****

Error JOB_NODISC in job <__main__.JobHandler instance at 0x8204b24>
4321 /bin/setserial /dev/ttyS0 spd_normal

****SIGCHILD*****

Killing child processes...

--------------------------------------------------------------------------

def sigterm(a,b):
print '\n****SIGTERM*****\n'
sys.exit()
print '\nDid not sys.exit()??!!\n'
killChildren()
os._exit(1)
print '\nDid not os._exit()??!!\n'

def killChildren():
global childPIDs
print '\n\nKilling child processes...'
for pid in childPIDs:
try:
print 'Terminating %d'%pid
os.kill(pid,signal.SIGTERM)
os.waitpid(pid,0)
except:
pass

def child_exit(a,b):
#childpid, status = os.wait()
print '\n****SIGCHILD*****\n'
pass
--
http://mail.python.org/mailman/listinfo/python-list
Jul 18 '05 #1
0 2388

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: José Joye | last post by:
I have a windows service where I create another appdomains. In the newly created AppDomain, I make use of a C library. If I issue an Abort(1) within this library, it simply hard stop my main...
2
by: spam | last post by:
I hope you will forgive the slightly OT post, but I haven't had any luck getting answers in the Unix/Solaris groups. I know the C++ standard doesn't mention signals because they are a...
4
by: Teresa | last post by:
Platform: Unix Tru 64 OSF 4.0D Problem: I spawned 3 processes. Proc A, B and C. My problem is that the parent process, proc A, sends SIGTERM to proc C; However, proc C does not exit some...
4
by: Jerry Camel | last post by:
Any insight here is greatly appreciated... (Eveything is in VB .NET) Here's the baisc app flow: ------------------------------------- Launch wrapper.exe: wrapper.exe registers for the...
4
by: News | last post by:
Hi Everyone, The attached code creates client connections to websphere queue managers and then processes an inquiry against them. The program functions when it gets options from the command...
3
by: Beavis | last post by:
I hate to repost a message, but I am still at the same point where I was when I originally posted, and hopefully someone else will see this one... Ok, so I have gone off and documented the...
6
by: Henry Law | last post by:
I'm trying to debug a Perl problem whose symptoms are that a running Perl process either doesn't receive, or fails inexplicably to handle, a SIGTERM sent from the OS during shutdown (Linux Fedora...
0
by: Robert Rawlins | last post by:
but mind the caveats: Thanks Tim, the main caveat which worries me is the fact that it doesn't get called when being killed by SIGTERM. When I look at implementing the application as Daemon will...
0
by: Cameron Simpson | last post by:
On 24Jul2008 17:30, Robert Rawlins <robert.rawlins@thinkbluemedia.co.ukwrote: | but mind the caveats: | | Thanks Tim, the main caveat which worries me is the fact that it doesn't get | called...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.