Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jan 1996 07:51:31 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        current@freebsd.org, dyson@freebsd.org
Subject:   new pipes fail several tests #1
Message-ID:  <199601302051.HAA25491@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
The Minix test programs found several bugs in the new pipe code.

#1: read() doesn't return -1/EAGAIN for EOF in non-blocking mode.  See
POSIX.1-1990 6.4.1.2(2).

Bruce

#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

#define check(what, expected)	assert((what, expected))

int main(void)
{
  char buf[1];
  int fd[2];
  int r;

  r = pipe(fd);
  check("pipe", r == 0);
  r = fcntl(fd[0], F_SETFL, O_NONBLOCK);
  check("fcntl", r == 0);
  r = read(fd[0], buf, 1);
  printf("read %d bytes, errno = %d\n", r, errno);
  check("read", r == -1);
  check("read", errno == EAGAIN);
  return 0;
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601302051.HAA25491>