X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-49.9 required=5.0 tests=AWL,BAYES_20,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,TW_JP,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Subject: Nonblocking serial ports From: "Yaakov (Cygwin/X)" To: cygwin AT cygwin DOT com Content-Type: multipart/mixed; boundary="=-afkzDIsQJg8YOmbF+gaJ" Date: Mon, 14 Jun 2010 00:59:39 -0500 Message-ID: <1276495179.5780.13.camel@YAAKOV04> Mime-Version: 1.0 Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --=-afkzDIsQJg8YOmbF+gaJ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit I came across this while working on getting my Palm to hook up to gnome-pilot over Bluetooth. COM3 is an incoming COM Port created within Bluetooth Settings, although the STC has the same results on COM1 (a standard serial port). Unlike pilot-link's tools and jpilot (all three use pilot-link's libpisock under the hood), gnome-pilot open()s a serial port with O_NONBLOCK when first started in order to initialize a GIOChannel, then later pi_bind()s a different fd pointing to the same port. Works great on Linux, but on Cygwin the latter call fails, as the serial port is already blocked by the first open() call. FWIW, both pilot-xfer and friends and jpilot work fine over the Bluetooth serial port, and all three work over the network. Attached is a STC. On Linux, this succeeds, but on Cygwin (both 1.7.5 and latest snapshot), it fails: second open(/dev/ttyS2) failed: Permission denied HTH, Yaakov --=-afkzDIsQJg8YOmbF+gaJ Content-Disposition: attachment; filename="test.c" Content-Type: text/x-csrc; name="test.c"; charset="UTF-8" Content-Transfer-Encoding: 7bit #include #include #include #include #include #define DEVICE "/dev/ttyS2" int main(void) { int fd; fd = open(DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd < 0) { fprintf(stderr, "first open(%s) failed: %s\n", DEVICE, strerror(errno)); return 1; } fd = open(DEVICE, O_RDWR); if (fd < 0) fprintf(stderr, "second open(%s) failed: %s\n", DEVICE, strerror(errno)); return 2; close(fd); return 0; } --=-afkzDIsQJg8YOmbF+gaJ Content-Type: text/plain; charset=us-ascii -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --=-afkzDIsQJg8YOmbF+gaJ--