On 15/03/12 13:50, Marcos wrote:
-- 8< --
> How do I get the PID of the exec command running espeak in foreground?
You can't; at least not from inside Tcl.
The Tcl command [exec] returns the exit status of the invoked
executable. See also the manual page for [exec].
So, [exec espeak $sometext] returns the exit status of the invoked
espeak program. And in case that espeak doesn't finish, the call to
[exec] doesn't return, i.o.w. "it blocks".
>
> Or how to know the end of the command execution running in the
> background?
By querying the operating system for the PID of the espeak process,
which you get from the following invocation (something that you already
know, apparently):
set PID [exec $pathToEspeak $someText]
Though Tcl doesn't provide any built-in commands to query the operating
system for process information, you could invoke another program or a
command provided by a Tcl extension to retrieve that information.
On unix derived operating systems you could use "top". On windows, I
wouldn't know of a separate program that outputs such information to a
channel from which another program (like Tcl) can read. But luckily, we
there exists a Tcl extension twapi of which I'm confident that it holds
commands to provide you with that information.
By the way, if your purpose were to interact with a running espeak
program (but your question doesn't indicate that), then you'd need the
[open] command as indicated by Arjen Markus.
HTH,
Erik Leunissen.
>
> Thanks for any suggestion,
> Marcos
--
leunissen@ nl | Merge the left part of these two lines into one,
e. hccnet. | respecting a character's position in a line.