This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Bot freezes after an exec

Old posts that have not been replied to for several years.
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Bot freezes after an exec

Post by Sir_Fz »

I'm writing a script that allows users to restart their (psy)bncs with a public command. I tried the following on my account:
.tcl exec sudo su Fz -c "killall -9 psybnc;cd ../psybnc; ./psybnc"
Now this did what it's supposed to do, but then the bot froze and I couldn't request chat or telnet to it anymore. Any suggestion ?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

hmm, probably the opened console doesnt close when psybnc switchs to background. haev you tried to use open | instead and just close the open console forcefully? Can't garantue it won't leave shadow consoles running somewhere in the memory ^-^.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

tried:
.tcl set this [set thisis [open "|sudo su Fz -c \"killall -9 psybnc;cd ../psybnc; ./psybnc\""]][close $thisis]
This only killed my psybnc but didn't restart it. The bot didn't freeze though. What's the reason behind this ?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

i cant really tell you why, but you could try to split the killall and ./psybnc into 2 open queries and use the cd tcl command to change the dir (better change it back afterwards with the backup made by pwd ^^), would be probably slower, but it would at least track down the error source, if still doesnt want to work :D.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
jsilvestre
Voice
Posts: 20
Joined: Sat Mar 05, 2005 6:02 am
Location: Lisbon, Portugal

Post by jsilvestre »

Try:

.tcl exec sudo su Fz -c "killall -9 psybnc && cd ../psybnc && ./psybnc"
Best Regards

José Eduardo Silvestre
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I noticed that the command I'm issuing isn't correct, I tried 'pwd' it gave the directory the bot's in nomatter what user I specify. So, until I figure out which shell command to use, we'll see if it works :P
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Sir_Fz wrote:I noticed that the command I'm issuing isn't correct, I tried 'pwd' it gave the directory the bot's in nomatter what user I specify. So, until I figure out which shell command to use, we'll see if it works :P
thats only natural, because the cd command in your exec/open line only changes the path for the current instance of bash (or better sudo in this case). thats why I suggested to really change the bots current directory :D.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I've managed to find the proper command, but now my problem is that using open I get the following error:
child process exited abnormally
while using exec, the command works but the bot freezes. Any ideas on how to handle this ?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

as said, to avoid freezing you have to use the non-blocking open. exec will always be in blocking mode.
you can addionally use catch {open ...} to ignore any returned errors.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

catch {set this [set yo [open "|sudo su Fz -c \"cd $mydir/psybnc;./psybnc\"]][close $yo]} error
returns "child process exited abnormally" in error and will not do the job.

Code: Select all

catch {exec sudo su Fz -c "cd $mydir/psybnc;./psybnc"} error
does the job, but the bot freezes.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Sir_Fz wrote:

Code: Select all

catch {set this [set yo [open "|sudo su Fz -c "cd $mydir/psybnc;./psybnc"]][close $yo]} error
i hope it is
[open "|sudo su Fz -c "cd $mydir/psybnc;./psybnc""]
the code above would be missing 1 close quote ^^

but besides this... very strange. If you believe the sudden close could cause the chield termination, you could try to "softly" close it via:
fconfigure $yo -blocking 0
fileevent $yo readable "close $yo"
but probably the error occurs while "open" is execute, so I think it would be unlogical to help ^^
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

The comany's owner is going to make a bash command on the shell, so all I have to exec is the command user and pass. That should fix the problem. Thanx :)
User avatar
Adrenalin
Voice
Posts: 21
Joined: Sat Jan 29, 2005 10:32 am
Location: Moldova
Contact:

Post by Adrenalin »

I'm not sure..
I think nohup should do the job..

catch {exec sudo su Fz -c "cd $mydir/psybnc;nohup ./psybnc"} error
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Code: Select all

NAME
       nohup - run a command immune to hangups, with output to a non-tty

SYNOPSIS
       nohup COMMAND [ARG]...
       nohup OPTION

DESCRIPTION
       Run COMMAND, ignoring hangup signals.

       --help display this help and exit

       --version
              output version information and exit
what was the signal hangup (kill -s SIGHUP <pid>" to do with a prozess causing a blocking behavior? I somehow doubt the prozess causes the stuck because it recieves the signal hangup :D.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
Adrenalin
Voice
Posts: 21
Joined: Sat Jan 29, 2005 10:32 am
Location: Moldova
Contact:

Post by Adrenalin »

Imo eggdrop stuck because it wait until the exec will return somethink.. Or until the executed proces will go to background or will end..
Maybe i'm wrong.. You could also try ./psybnc &(but..if you log out, your background task might get killed automatically).. Just some sugestions ;)
Locked