in reply to Re: Re: Re: Re: Threads Problem!
in thread Threads Problem!

If you think exiting is the problem, you might want to have a look at Thread::Exit. However, I doubt whether that will make any diifference.

Please try to re-create the problem with as little source as possible. I cannot reproduce the behaviour on my systems, so it must be something specific to your situation that is causing the zombies.

What OS are you using anyway? Maybe the problem is OS related.

Liz

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Threads Problem!
by Anonymous Monk on Nov 03, 2003 at 19:54 UTC
    Thanx for effort liz :)

    This is a sample of code that exists. i've left all the use module::module; for you to see what i use in the entire bot.

    This bot just sends TEST TEST to a user who does .help

    With threaded perl it works good. starts a process then it exits it when done but loads alot of memory. With forks it works but it doesnt end the process, the extra bot.pl is still there when ps -aux | grep bot.pl

    bot.pl
    #!/usr/bin/perl -w use Net::IRC; use strict; use HTTP::Response; use HTML::LinkExtor; use URI::URL; use DBI; use Data::Dumper; use File::Basename; use File::Path; use vars qw($search $text $ftp); use Net::FTP; use Config::IniFiles; use Number::Format; use LWP::UserAgent; use HTTP::Request; #use Thread; use FileHandle; use Time::HiRes qw(usleep ualarm gettimeofday tv_interval); use Date::Calc qw(:all); use Net::Cmd; use forks; my $ircserver = '127.0.0.1'; + my $ircport = '7777'; + our $ircchannel = '#test'; + my $ircbotname = 'labrat'; + my $joingreet = 'hello fellas'; + my $nickgreet = 'welcome '; my $ircname = 'labrat'; + my $username = 'labrat'; + my $localip = '192.168.0.1'; + my $pid = $$; our $bold = chr(2); print "Preparing to load required files!!\n"; ### MODULES ### require "help_module.pl"; print "Required Files loaded OK!!\n"; sub ircinfo { our $irc = new Net::IRC; our $conn = $irc->newconn( Server => $ircserver, Port => $ircport, Nick => $ircbotname, Ircname => $ircname, LocalAddr => $localip, Password => 'fucknuts.', Username => $username ); $conn->{channel} = $ircchannel; $conn->add_handler('join', \&on_join); $conn->add_handler('part', \&on_part); $conn->add_handler('public', \&on_public); $conn->add_handler('376', \&on_connect); $conn->add_global_handler('disconnect', \&reconnect); $conn->add_global_handler(433, \&on_nick_taken); $irc->start(); } sub reconnect { system("./bot.pl &"); system("kill -9 $pid"); } sub default { my ($conn, $event) = @_; print Dumper($event); } sub on_connect { my $conn = shift; $conn->join($conn->{channel}); $conn->privmsg($conn->{channel}, $joingreet); $conn->{connected} = 1; $conn->add_global_handler(433, \&on_nick_taken); } sub on_nick_taken { my ($self) = shift; $self->nick(substr($self->nick, -1) . substr($self->nick, 0, 8)); } sub on_join { my ($conn, $event) = @_; my $nick = $event->{nick}; my $host = $event->{host}; $conn->privmsg($conn->{channel}, "$nickgreet," . $bold . " $nick" +. $bold ); } sub on_part { my ($conn, $event) = @_; my $nick = $event->{nick}; $conn->privmsg($conn->{channel}, "Goodbye, $nick!"); } sub on_public { my ($conn, $event) = @_; my $text = $event->{args}[0]; if (lc substr($text,0,5) eq ".help") { my $info = substr($text,6); my $helpthr = threads->new(\&help, "$event->{nick}"); $helpthr->detach; } } print "Starting Bot!!\n"; ircinfo();
    This is the help_module.pl
    sub help { my $nick = shift; $conn->privmsg($nick, $bold . "TEST " . $bold . "TEST"); last(); # Here i've tried with last; exit(); return; } 1;
    I'm really stuck on this :/ I dont have a singel clue. Might be my irc module thas poorly written to. Hope you get something out of it :)

    /Chris
Re: Re: Re: Re: Re: Re: Threads Problem!
by Anonymous Monk on Nov 03, 2003 at 16:44 UTC
    Ok i will try to write a little source that have the same problem as the one i use now.

    i'm running Linux merlin 2.4.20-gentoo-r7 #5 SMP Wed Oct 22 01:11:47 CEST 2003 i686 Pentium III (Coppermine) GenuineIntel GNU/Linux

    I try thread exit and then write a little sample for you :)