Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!

Members: 0
Guests: 6
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » DNS resolver: defunct process...
Forum Rules | Mark all | Recent Posts

DNS resolver: defunct processes
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Jan 8, 2008, 4:50 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

So I'm running the DNS resolver snippet on my MUD. But I keep getting defunct processes.
zeno       808  0.0  0.0  89028  1212 ?        S    Jan02   0:00 /bin/csh -f ./startup
zeno      3392  0.0  0.0  89028   488 ?        S     2007   0:00 /bin/csh -f ./startup
zeno      3604  0.1  0.6  55128 12120 ?        SN   Jan02   8:40 biyg 1802 hotboot 5 -1
zeno      4825  0.0  0.0      0     0 ?        ZN   Jan07   0:00 [resolver] <defunct>
zeno     14678  0.0  0.0      0     0 ?        ZN   Jan07   0:00 [resolver] <defunct>
zeno     18494  0.1  0.8  59172 16828 ?        SN    2007  37:35 biyg 1801 hotboot 5 -1
zeno     24693  0.0  0.1  85684  2456 ?        S    16:40   0:00 sshd: zeno@pts/0
zeno     24694  0.0  0.0  89276  1616 pts/0    Ss   16:40   0:00 -bash
zeno     24803  0.0  0.0      0     0 ?        ZN   Jan06   0:00 [resolver] <defunct>
zeno     25444  0.0  0.0  87040   912 pts/0    R+   16:47   0:00 ps ux


Any ideas how to fix this? Really need to figure it out, but I'm no good at debugging child processes... I'm close to hitting my process limit.
       
Post is unread #2 Jan 8, 2008, 5:29 pm   Last edited Jan 8, 2008, 6:48 pm by Kasji
Go to the top of the page
Go to the bottom of the page

Kasji
Apprentice
GroupMembers
Posts62
JoinedDec 23, 2007

Your parent process needs to use wait() to cleanup zombie child processes. Normally wait() will block, but there is a version that is non-blocking using a flag called WNOHANG. I recommend reading "man wait" on your *nix system. It will check to see if any child processes have exited, and clean-up those that have.

The implementation you use is a matter of choice, but I would probably attach a signal handler to SIGCHLD which is called by the OS when your child process exits. You can use that handler to call wait() or waitpid() or whatever, and clean-up the zombie child processes.

If you want more info, I suggest the book Advanced Linux Programming by Mark Mitchell, Jeffrey Oldham, and Alex Samuel. Published by NewRiders. ISBN 0-7357-1043-0

EDIT:
Signal handler:
int child_exit_status = 0;

static void clean_up_child_process (int signal_number)
{
/* Clean up the child process. */
int status;
wait (&status);
/* Store its exit status in a global variable. */
child_exit_status = status;
}


Add to comm.c, find:
   signal( SIGPIPE, SIG_IGN );
   signal( SIGALRM, caught_alarm );

Change to:
   signal( SIGPIPE, SIG_IGN );
   signal( SIGALRM, caught_alarm );
   signal( SIGCHLD, clean_up_child_process );


Next go to dns.c and find:
 if( d->ipid != -1 )
   {
      waitpid( d->ipid, &status, 0 );
      d->ipid = -1;
   }

Comment it out, because if we have two calls to wait, then one will end up hanging, and it would cause the MUD to stall.

This -should- work, but I can't test it, as I don't have the DNS resolver code.
       
Post is unread #3 Jan 12, 2008, 12:07 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

I'd appreciate it if someone who does have the DNS code installed, or is using SmaugFUSS 1.7 or 1.8, could check this out and make sure it's working properly.
       
Post is unread #4 Jan 13, 2008, 9:39 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Gonna throw this up on my dev port, see how it goes. I'll let it sit for a few days, then move to my main port and see how it is.
       
Post is unread #5 Jan 16, 2008, 9:02 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

I put it on main. 24 hours or so have passed, and no zombie childs yet.
       
Pages:<< prev 1 next >>