waiting for an exec'ed process to finish 
Author Message
 waiting for an exec'ed process to finish

Hi all,

I'm trying to write a tcl/Tk script that executes an external program,
and waits until the program finishes.
I can't find a way to do that. Although "exec" returns the process
numbers, I can't wait on them, because the "wait" command doesn't work
(I think that's because it has to be run from a parent process). Does
anybody know of a solution to this problem? (preferably without using
extensions)

I'm using tcl8.0b1 with Tk8.0b1.

Best Regards,
Tomer



Fri, 27 Jul 2001 03:00:00 GMT  
 waiting for an exec'ed process to finish
Hmmm....
My tcl 8.0 documentation does not mention a "wait" command.

If you're trying to use the unix wait command, maybe you need to "exec
wait <pid>" to get the tcl script to pause.

Dave LeBlanc



Quote:
>Hi all,

>I'm trying to write a tcl/Tk script that executes an external program,
>and waits until the program finishes.
>I can't find a way to do that. Although "exec" returns the process
>numbers, I can't wait on them, because the "wait" command doesn't work
>(I think that's because it has to be run from a parent process). Does
>anybody know of a solution to this problem? (preferably without using
>extensions)

>I'm using tcl8.0b1 with Tk8.0b1.

>Best Regards,
>Tomer



Sat, 28 Jul 2001 03:00:00 GMT  
 waiting for an exec'ed process to finish

Quote:

> I'm trying to write a tcl/Tk script that executes an external program,
> and waits until the program finishes.
> I can't find a way to do that. Although "exec" returns the process
> numbers, I can't wait on them, because the "wait" command doesn't work

If you want to do absolutely nothing while you are waiting for a single
process, simply use [exec] without '&'. It does a wait() internally.

If you want to do something in the meantime (e.g. be responsive to GUI
events, like refreshes), then use [open "|cmd args" r] and fileevent.
Consume whatever comes down the pipe with [gets] or a nonblocking
[read], and when you hit EOF it's a (nearlt perfect) hint that the child
has died (then, don't forget to close the  pipe). This has the
additional advantage of doing a 'parallel' wait(), meaning that you
don't have to know which one will die first.

Now if you'r under windows, you'll have to take special steps to make
fileevents work on pipes:

        - either use Tcl 8.1*
        - or use Gordon Chaffee's patched 8.0p2, found as binaries in
ExpectNT5.21.
        - or use Robin Becker's patched 8.0.3, but beware it still has some bad
interactions with Tk (or at least it did last time I checked :^).

-Alex



Sat, 28 Jul 2001 03:00:00 GMT  
 waiting for an exec'ed process to finish

: I'm trying to write a tcl/Tk script that executes an external program,
: and waits until the program finishes.
: I can't find a way to do that. Although "exec" returns the process
: numbers, I can't wait on them, because the "wait" command doesn't work
: (I think that's because it has to be run from a parent process). Does
: anybody know of a solution to this problem? (preferably without using
: extensions)

: I'm using tcl8.0b1 with Tk8.0b1.
                  ^^           ^^

If you're really using the "beta-1" version of Tcl/Tk 8.0, you really
need to upgrade badly.  There have been lots and lots of bugs fixed
since this version.  The latest 8.0 version is 8.0.4 (that's in patch
level 4, not beta-4).  My guess though, is that you are referring to
the 8.1b1 release.

--gah



Sat, 28 Jul 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to detect that an exec'd process has finished

2. interaction with exec'ed process

3. How to wait until exec is finished?

4. cgi-bin "exec": error waiting for process to exit: No child processes

5. RUN used in program, but not waiting for process to finish

6. Waiting for processes to finish under Solaris

7. Q: how to get pid of 'start'ed process (WNT, os.system)

8. Exec waits for all sub-processes on UNIX

9. exec: waiting for process to exit

10. Using import in an exec'ed string

11. return val of exec'ed prog

12. How to pass arguments to program been exec'ed

 

 
Powered by phpBB® Forum Software