The main question of my current task is to start process from Tcl environment (using exec cmd.) with I/O redirection to parent process (Tcl) and when parent process unexpectedly stopped I'd like to automatically stop the child process. But there is a caveat: for I/O redirection case child process doesn't stop. The problem is complexed because child process can't be modified.
I've found the next thread How to make child process die after parent exits? where solution has been found for C language and without I/O redirection.
So for example, I use the next command in Tcl:
exec ping $SERVER_NAME >@ stdout 2>@ stderr
This command redirect output of stdout and stderr to the parent process (Tcl). But I need to run something like that:
exec sh -c "set -o monitor; ping $SERVER_NAME >@ stdout 2>@ & read dummy; kill %1"
And in the command above output of stdout and stderr goes into "sh" process but I'd like to get it in my parent process. So I have the several question:
- What mean symbol "@" in the following command (may be you could get a link)?
- How to make I/O redirection to the Tcl process?
- How to stop child process (ping in example) if Tcl process unexpectedly stopped?