LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-06-2011, 01:56 AM   #1
Dogza
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Rep: Reputation: Disabled
Debugging hanging child process with strace


Hi All,

I am using a script the spawns child processes but once in a while a child process won't go away which causes the script stop working.
I have done a strace on a child process that stops working, with the following results:

Quote:
rt_sigaction(SIGALRM, {SIG_IGN}, {SIG_DFL}, 8) = 0
alarm(0) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
accept(3,
A good working child process gives the following results:

Quote:
rt_sigaction(SIGALRM, {SIG_IGN}, {SIG_DFL}, 8) = 0
alarm(0) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
accept(3, {sa_family=AF_INET, sin_port=htons(34607), sin_addr=inet_addr("127.0.0.1")}, [17179869200]) = 4
rt_sigaction(SIGALRM, {SIG_IGN}, {SIG_IGN}, 8) = 0
alarm(0) = 0
close(3) = 0
getsockname(4, {sa_family=AF_INET, sin_port=htons(2000), sin_addr=inet_addr("127.0.0.1")}, [17179869200]) = 0
select(5, [0 4], NULL, NULL, NULL) = 2 (in [0 4])
read(4, ""..., 8192) = 0
read(0, ""..., 8192) = 0
close(0) = 0
close(4) = 0
exit_group(0) = ?
I notices the 'accept(3,' but I don't really know what is means or how to read it. I hope that someone can help me to find the cause of this problem.

Thanks in advance!
 
Old 06-06-2011, 06:56 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

It looks like this is a server program that listens on some TCP/IP port and accepts incoming client connections.

It also look like the "accept()" code uses "alarm()" to trigger some kind of timeout: "Do something if a new connection doesn't arrive within N seconds".

By default, "accept()" will block: it will hang forever if nobody ever connects.

That's why they implemented the "alarm()" - to break out if a new connection DOESN'T arrive promptly.

"alarm(0)", as opposed to "alarm (n)", CLEARS any alarm that might be set. So both your strace's are CLEARING an alarm that was presumably set somewhere else.

The "good" case (your second example) is where a connection DID arrive.

The "bad" case (your first example) indicates that your child process is waiting for an incoming connection. Which will presumably never arrive.

So your mission is to figure out who is supposed to connect to the child, and why that somebody is failing to do so.

'Hope that helps .. PSM
 
Old 06-15-2011, 02:55 AM   #3
Dogza
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi Paulsm4,

That helped me a lot. I noticed that Netcat is making connections and it is using TCP/IP. So I am going to try to set a timeout value to see if that fix the problem.

Thank you very much!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Child THREAD and Child PROCESS whho Linux - Newbie 12 02-16-2015 12:22 AM
Under which circumstances a child process creates another child process using fork? mitsulas Programming 3 12-08-2009 08:16 AM
How to kill a Child and all its subsequent child process in C shayer009 Programming 3 12-04-2007 12:40 AM
Killing a child process from another child marri Programming 6 10-01-2004 07:08 PM
strace restoring my process`s functionality dschulte Programming 1 08-01-2003 12:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration