<type>documentation</type>
<domain>debug</domain>
<id>debugging-externally-launched-code</id>
<title>Externally Launched Process Behavior</title>
<date>$Date$</date>
<version>$Revision$</version>
<product>per+</product>

This section describes what happens if ``wingdbstub`` cannot attach to Wing,
and how termination of remote debug works.

**Failure to Attach to IDE**

Whenever the debugger cannot contact Wing during ``import wingdbstub``, for example if the
IDE is not running or can't be reached, then the debug program will be run without debug.
This allows debug-enabled web tasks and other programs to work normally when Wing is not
present.

You can force the debug process to exit in this case by setting the ``kExitOnFailure``
flag in ``wingdbstub.py``.

~~~if WINGPRO:
In Wing Pro, it is possible attach to processes that import ``wingdbstub`` but start
without debug. See `Attaching <ref:debug/attaching-and-detaching>`__ for details.
~~~

**Enabling Process Termination**

By default, Wing recognizes externally launched processes and disables process termination
for them.  The `Debugger > Listening > Kill Externally Launched Processes
<script:show_preferences_gui#prefname="debug.enable-kill-external">`__ preference can
be set to enable Wing to terminate also externally launched processes.

**Avoiding Connection Timeout**

Some environments may preemptively close the debug connection from the outside if there
is no activity over some period of time.  To prevent this from happening, set the 
`Debugger > Advanced > Connection Keep-Alive <script:show_preferences_gui#prefname="debug.send-keep-alive-seconds">`__
preference to the number of seconds between keep-alive messages.