Tcl Source Code

Ticket Change Details
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to
or submit via the online form by Aug 20.

Artifact ID: 4fea181e24e859144d53334703c640097536fce1
Ticket: 2413550fffffffffffffffffffffffffffffffff
Avoid double-open of serial ports on Windows
User & Date: oehhar 2014-01-30 11:04:54

  1. Change assignee to "aku"
  2. Change closer to "nobody"
  3. Change comment to:

    Currently, opening a serial port on Windows involves a double-open: (1) open generically (2) check the handle for serialness (3) reopen with OVERLAPPED flag if serial.

    This causes trouble in some setups where the open/close (and its timing) is not transparent to the underlying driver, like bluetooth RFCOMM profile. See

    for a concrete example.

    A simple and efficient solution is to use a "name hint" to detect COM ports by their filename instead of resorting to a syscall to detect serialness after the fact.

    Rolf Shroedter has suggested that at least the two following patterns should be detected:

    COM[0-9]:? \\.\COM[0-9]+:?

    It also turns out that the first one should be applied to the [file tail], since \foo\bar\COM4 is also a valid serial port reference in Windows.

    However, we believe that a good strategy should be to make only a reasonable effort in that direction, leaving tricky cases handled by the current behavior; this in order not to spoil the performance of [open] for non-serials.

    A patch will be uploaded shortly to support just the above two patterns.

  4. Change icomment to "Patch applied for tcl 8.5 in branch [84307fe13f]"
  5. Change login to "oehhar"
  6. Change mimetype to "text/x-fossil-wiki"
  7. Change severity to "Minor"
  8. Change username to "oehhar"