| View previous topic :: View next topic |
| Author |
Message |
needHelp Voice
Joined: 03 Nov 2007 Posts: 2
|
Posted: Sat Nov 03, 2007 8:31 pm Post subject: launching a proc in background? |
|
|
hi, i wrote a proc for my eggdrop which takes some time.
while running this proc the eggdrop cant respond to other commands and sometimes i get ping timeout.
the proc has to take the long time so i dont want to change anything on it.
instead im looking for a method to call the proc from the binded proc to launch in background or in a child process.
i already tried forking but without success.
any1 here has an idea?
thx in advance. |
|
| Back to top |
|
 |
TCL_no_TK Owner

Joined: 25 Aug 2006 Posts: 509 Location: England, Yorkshire
|
Posted: Sun Nov 04, 2007 10:34 pm Post subject: |
|
|
I dont know if thats really possible, thou it all depends on what the script dose? If its something like running a progeram or an exacutable, that would probably ...i would think could easyerly be done. But other than that, i could recommend execting tclsh and running it that way? or use of a pipe or unix sock maybe? _________________ TCL the misunderstood |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Nov 05, 2007 10:02 am Post subject: |
|
|
Could usually be done quite easily..
Depending on system, this might work:
A slightly more complicated approach, that also allows you to access the stdin and stdout pipes through file-handles
| Code: | proc readcmd {process} {
if {[gets $process data] < 0} {
if {[eof $process]} {
close $chan
return
}
} {
#Process the output stored in $data, or just ignore it?
}
}
set pid [open "| command" "RDWR"]
fconfigure $pid -blocking 0
fileevent $pid -readable [list readcmd $pid]
|
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
needHelp Voice
Joined: 03 Nov 2007 Posts: 2
|
Posted: Mon Nov 05, 2007 11:29 am Post subject: |
|
|
as i already said i dont want to run an executable.
But i think i solved it on my own using Thread 2.6 package. |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Nov 05, 2007 6:57 pm Post subject: |
|
|
Registering a timer would still cause it to be executed within the same thread, causing the same blocking condition.
I have no experience using the Thread package with eggies myself, would be nice to hear if it goes all well. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|