Date: Fri, 14 Jun 1996 18:27:37 +1000 (EST) From: John Birrell <cimaxp1!jb@werple.net.au> To: hackers@FreeBSD.org Cc: jb@cimlogic.com.au Subject: Nonblocking writes to pipes hang Message-ID: <199606140826.SAA21378@melb.werple.net.au>
next in thread | raw e-mail | index | archive | help
G'day, We're having problems with non-blocking writes to pipes under FreeBSD 2.1R and 2.2-current (supped middle of last week). The test program (below) gives the following results: OSF/1 V3.1 65536 bytes written to pipe HPUX V10.01 8192 bytes written to pipe NetBSD 1.1A/i386 4096 bytes written to pipe The program on either FreeBSD 2.1R or 2.2-current just hangs. Only a kill -9 will interrupt it. Can anyone explain what is going on? #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <unistd.h> int main() { char *p_buff; int desc[2]; int ierr = 0; long num; size_t buffsize = 100000; if ((p_buff = (char *) malloc(buffsize)) == NULL) { printf("Error allocating %lu bytes\n", (unsigned long) buffsize); ierr = 1; } else { memset(p_buff, 'a', buffsize); *(p_buff + buffsize - 1) = '\0'; if (pipe(desc) != 0) { printf("Error %d from pipe()\n", errno); ierr = 1; } else if (fcntl(desc[1], F_SETFL, O_NONBLOCK) != 0) { printf("Error %d from pipe()\n", errno); ierr = 1; } else if ((num = write(desc[1], p_buff, buffsize)) < 0) { printf("Error %d from write()\n", errno); ierr = 1; } else { printf("%ld bytes written to pipe\n", num); } } return (ierr); } Thanks, -- John Birrell CIMlogic Pty Ltd jb@cimlogic.com.au 119 Cecil Street Ph +61 3 9690 6900 South Melbourne Vic 3205 Fax +61 3 9690 6650 Australia Mob +61 18 353 137
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606140826.SAA21378>