From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from endymion.arp.harvard.edu (mercury.arp.harvard.edu [140.247.179.71]) by sourceware.org (Postfix) with ESMTPS id 14FE6385840D for ; Thu, 13 Jan 2022 17:37:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14FE6385840D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=huarp.harvard.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=huarp.harvard.edu Received: from [192.168.7.23] (pool-108-20-233-29.bstnma.fios.verizon.net [108.20.233.29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by endymion.arp.harvard.edu (Postfix) with ESMTPSA id 9AF3C26CB11 for ; Thu, 13 Jan 2022 12:37:56 -0500 (EST) Message-ID: <5255058c-74e0-f351-3c91-e63a54a1e323@huarp.harvard.edu> Date: Thu, 13 Jan 2022 12:37:56 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: en-US From: Norton Allen To: "cygwin@cygwin.com" Subject: character device canonical mode Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2022 17:37:59 -0000 Apparently Cygwin does not support canonical mode on serial devices. On input canonical mode will wait for a newline before returning from a read(). The bit is cleared/ignored by tcsetattr() as demonstrated by a subsequent tcgetattr() in the test program below. I am wondering if this is because of a fundamental difference between the Windows serial device model and POSIX or just because the appropriate mappings haven't been implemented. (I have studiously avoided Windows programming for decades, and Cygwin has been my enabler!) My test program: #include #include #include #include #include #include void check_rv(int rv, const char *where) {   if (rv) {     printf("Error %s: %d %s\n", where, errno, strerror(errno));     exit(1);   } } int main(int argc, char **argv) {   termios termios_p;   if (argc != 2) {     printf("Must specify a serial device\n");     exit(1);   }   int fd = open(argv[1], O_RDWR | O_NONBLOCK);   check_rv(fd == -1, "opening serial device");   check_rv(tcgetattr(fd, &termios_p), "from tcgetattr()");   printf("c_lflag = 0x%X after open\n", termios_p.c_lflag);   termios_p.c_lflag |= ICANON;   printf("c_lflag = 0x%X to pass to tcsetattr()\n", termios_p.c_lflag);   check_rv(tcsetattr(fd, TCSANOW, &termios_p), "from tcsetattr()");   check_rv(tcgetattr(fd, &termios_p), "from 2nd tcgetattr()");   printf("c_lflag = 0x%X after tcsetattr()\n", termios_p.c_lflag);   return 0; }