From: S-Y. Chen on 13 Jul 2010 12:01 Dear All, I am having a very big head about a problem. I am wondering if anyone can help me here. I have to constantly calling a program through "exec", for example exec program_a.exe -input something.txt This will be called on in a loop inside a script. The problem is, this program_a.exe seems never close itself and return to the system. So whenever this line is executed, I will get the result I want, but tcl will stop with error. Then the loop is terminated. So I use catch {exec program_a.exe -input something.txt} Now the loop goes on, but program_a.exe is still in the memory. Finally there are too many program_a.exe in the memory, eating up all the resources, and the whole system crashes............. Is there any way that, each time I call program_a.exe, I can let tcl wait for program_a.exe to finish the job (it can sometimes take hours or so), kill this thread and go on ? I know it will be better to close this program inside its own scope, but it is just difficult to do that. Any help will be greatly appreciated. Regards S-Y. Chen Regards S-Y. Chen
From: APN on 13 Jul 2010 12:41 On Jul 13, 9:01 pm, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > Dear All, > > I am having a very big head about a problem. I am wondering if anyone > can help me here. > > I have to constantly calling a program through "exec", for example > > exec program_a.exe -input something.txt > > This will be called on in a loop inside a script. The problem is, this > program_a.exe seems never close itself and return to the system. So > whenever this line is executed, I will get the result I want, but tcl > will stop with error. Then the loop is terminated. > > So I use > > catch {exec program_a.exe -input something.txt} > > Now the loop goes on, but program_a.exe is still in the memory. > Finally there are too many program_a.exe in the memory, eating up all > the resources, and the whole system crashes............. > > Is there any way that, each time I call program_a.exe, I can let tcl > wait for program_a.exe to finish the job (it can sometimes take hours > or so), kill this thread and go on ? > > I know it will be better to close this program inside its own scope, > but it is just difficult to do that. > > Any help will be greatly appreciated. > > Regards > S-Y. Chen > > Regards > S-Y. Chen Do you know why Tcl is terminating with an error ? What does $::errorInfo show? Does the exec'ed program write to stderr ? That would be treated as an error by Tcl unless you redirect (I think). If you don't mind using an extension, the twapi extension (http:// twapi.magicsplat.com) has the end_process command to terminate processes on Windows. However, the question is - how will you know when the exec'ed program has finished doing its thing so you can terminate it? /Ashok
From: S-Y. Chen on 13 Jul 2010 12:54 On Jul 14, 12:41 am, APN <palm...(a)yahoo.com> wrote: > On Jul 13, 9:01 pm, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > > > > > Dear All, > > > I am having a very big head about a problem. I am wondering if anyone > > can help me here. > > > I have to constantly calling a program through "exec", for example > > > exec program_a.exe -input something.txt > > > This will be called on in a loop inside a script. The problem is, this > > program_a.exe seems never close itself and return to the system. So > > whenever this line is executed, I will get the result I want, but tcl > > will stop with error. Then the loop is terminated. > > > So I use > > > catch {exec program_a.exe -input something.txt} > > > Now the loop goes on, but program_a.exe is still in the memory. > > Finally there are too many program_a.exe in the memory, eating up all > > the resources, and the whole system crashes............. > > > Is there any way that, each time I call program_a.exe, I can let tcl > > wait for program_a.exe to finish the job (it can sometimes take hours > > or so), kill this thread and go on ? > > > I know it will be better to close this program inside its own scope, > > but it is just difficult to do that. > > > Any help will be greatly appreciated. > > > Regards > > S-Y. Chen > > > Regards > > S-Y. Chen > > Do you know why Tcl is terminating with an error ? What does > $::errorInfo show? Does the exec'ed program write to stderr ? That > would be treated as an error by Tcl unless you redirect (I think). > > If you don't mind using an extension, the twapi extension (http:// > twapi.magicsplat.com) has the end_process command to terminate > processes on Windows. However, the question is - how will you know > when the exec'ed program has finished doing its thing so you can > terminate it? > > /Ashok No I don't think it writes to stderr. I had a similar problem before, and tcl receives error message just because I didn't put an "exit" in the end of that program input. Otherwise nothing is wrong. The program just didn't return back, and I need to kill it. Regards S-Y. Chen
From: S-Y. Chen on 13 Jul 2010 13:02 Also, errorInfo said that "child process exited abnormally" on this exec command Regards S-Y. Chen
|
Pages: 1 Prev: exec converting / to \ Next: Parsing XMLs including special characters |