Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Sep 2000 19:50:56 +0400
From:      "Andrey A. Chernov" <ache@nagual.pp.ru>
To:        current@freebsd.org
Subject:   FIFOs & select: what about our implementation?
Message-ID:  <20000905195056.A67326@nagual.pp.ru>

next in thread | raw e-mail | index | archive | help
Consider this comment comes from screen(1):

/*
 * Define this if your system exits select() immediatly if a pipe is
 * opened read-only and no writer has opened it.
 */
#define BROKEN_PIPE 1

We have broken(?) pipe, according to this statement. At least, we have
select return code -1 with wrong errno == 0.

I attach the test for it below. The question is: what about our fifo
select (actually poll) implementation? Is it really broken, or is it a
feature? What standards says? If this is a feature, at least errno must be
fixed.

-----------------------------------------------------
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/stat.h>

char *fin = "/tmp/conftest$$";

main()
{
  struct timeval tv;
  int r, x;

  unlink(fin);
  if (mkfifo(fin, 0600))
    exit(1);
  close(0);
  if (open(fin, O_RDONLY|O_NONBLOCK))
    exit(1);
  r = 1;
  tv.tv_sec = 1;
  tv.tv_usec = 0;
  if (select(1, &r, 0, 0, &tv)) {
    perror("select");
    exit(1);
  }
  exit(0);
}
-----------------------------------------------------
-- 
Andrey A. Chernov
<ache@nagual.pp.ru>
http://ache.pp.ru/


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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