Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 From: Dave Johnson MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16089.35333.701156.506551@wellington.i202.centerclick.org> Date: Sun, 1 Jun 2003 01:07:17 -0400 To: cygwin AT cygwin DOT com Subject: O_NONBLOCK has no effect on stdout Setting stdout to non-blocking doesn't have an effect, calls to write() and the like block the process until the blocking condition is removed. Note that the fcntl() returns success. Running the below test program produces: under cygwin: $ ./test Starting, sleeping 2 seconds, hit ctrl-s test return=6, errno=No error, time=3903ms under linux and others: $ ./test Starting, sleeping 2 seconds, hit ctrl-s return=-1, errno=Resource temporarily unavailable, time=0ms I'm running: CYGWIN_NT-5.0 yorktown 1.3.22(0.78/3/2) 2003-03-18 09:20 i686 unknown unknown Cygwin test program: #include #include #include #include #include #include #include #include #include int main (int argc, char *argv[]) { struct timeval start_tv, end_tv; ssize_t callval; int callval2; printf("Starting, sleeping 2 seconds, hit ctrl-s\r\n"); sleep (2); callval2 = fcntl(fileno(stdout), F_SETFL, fcntl(fileno(stdout), F_GETFL, 0) | O_NONBLOCK); if (callval2 < 0) { fprintf(stderr,"set nonblocking failed: %s", strerror(errno)); } gettimeofday(&start_tv,NULL); errno=0; callval = write(fileno(stdout), "test\r\n", 6); gettimeofday(&end_tv,NULL); callval2 = fcntl(fileno(stdout), F_SETFL, fcntl(fileno(stdout), F_GETFL, 0) & ~O_NONBLOCK); if (callval2 < 0) { fprintf(stderr,"set nonblocking failed: %s", strerror(errno)); } printf("return=%d, errno=%s, time=%ldms\n", callval, strerror(errno), ((end_tv.tv_sec - start_tv.tv_sec) * 1000) + ((end_tv.tv_usec/1000) - (start_tv.tv_usec/1000))); exit(0); } -- Dave k -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/