From owner-freebsd-hackers Fri Jun 14 02:01:51 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id CAA19410 for hackers-outgoing; Fri, 14 Jun 1996 02:01:51 -0700 (PDT) Received: from melb.werple.net.au (melb.werple.net.au [203.9.190.18]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id CAA19401 for ; Fri, 14 Jun 1996 02:01:47 -0700 (PDT) Received: from cimaxp1.UUCP (uucp@localhost) by melb.werple.net.au (8.7.5/8.7.3/2) with UUCP id SAA21378 for hackers@FreeBSD.org; Fri, 14 Jun 1996 18:26:56 +1000 (EST) Message-Id: <199606140826.SAA21378@melb.werple.net.au> Received: by cimaxp1.cimlogic.com.au; (5.65/1.1.8.2/10Sep95-0953AM) id AA06477; Fri, 14 Jun 1996 18:27:38 +1000 From: John Birrell Subject: Nonblocking writes to pipes hang To: hackers@FreeBSD.org Date: Fri, 14 Jun 1996 18:27:37 +1000 (EST) Cc: jb@cimlogic.com.au X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk 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 #include #include #include #include #include #include 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