set strSpawn { spawn -open [open "| myapp args 2>logfile.txt" w
+] }
    if [catch $strSpawn reason]  {
        <perform failure notification using $reason>
    }  else  {
        <successful spawn>
                  :
    }
    expect  {
        -i lstSpawnIDs
        default  {
            <perform normal eof/timeout handling>
        }
    }
However I also acknowledge the footnote on pg. 296:  " 'spawn -open'
returns a process id of 0 to indicate no process was spawned.  There
is no process to kill."
The above code works most of the time, but produces "spawn_id expxxx
not open" under certain circumstances.  This indicates that a spawn_id
was generated for myapp but some failure occured, closing myapp.  I
have determined that the failure clause above is never invoked,
whether the spawn/open is successful or not, presumably because of the
footnote (process ID always = 0).
So my main question is:  What's the best means of determining the
success/failure of the launch of myapp?  I.e. I need to intercept the
"spawn_id expxxx not open" dialog and take appropriate action (retry,
abort myapp etc.).
I'd also be interested in a fuller understanding of the apparent
dichotomy of the footnote and the vertical bar indicating that a
process is actually spawned (which is indeed the case!).
Thanks in advance for any clarifications,
  Lisa
> 
> I'd also be interested in a fuller understanding of the apparent
> dichotomy of the footnote and the vertical bar indicating that a
> process is actually spawned (which is indeed the case!).
The [spawn] does not create a process.
But your [open "|........"] does.
the ~functional equivalent would be:
spawn myapp args
the -open option is imho more usefull for talking
to a serial line or similar.
If you have a process hanging on the fd you can
as well spawn this app directly.
uwe