diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-11-05 15:43:05 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-11-05 15:43:05 +0000 |
commit | 4e980851eda412ed097ed37ba3d34f94c8f3a8ca (patch) | |
tree | 417efcfb71f33d9e6fad02d08c080f08263f8006 /regress/sys/kern/pread | |
parent | 0ce3dac9749d60062a87d3dab4a78725d2dfc6de (diff) |
Verify this fails with ESPIPE on ttys
Diffstat (limited to 'regress/sys/kern/pread')
-rw-r--r-- | regress/sys/kern/pread/pread.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/regress/sys/kern/pread/pread.c b/regress/sys/kern/pread/pread.c index c4640dd1a32..4a57babdb1b 100644 --- a/regress/sys/kern/pread/pread.c +++ b/regress/sys/kern/pread/pread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pread.c,v 1.2 2003/07/31 21:48:09 deraadt Exp $ */ +/* $OpenBSD: pread.c,v 1.3 2011/11/05 15:43:04 guenther Exp $ */ /* * Written by Artur Grabowski <art@openbsd.org> 2002 Public Domain. */ @@ -6,6 +6,7 @@ #include <stdlib.h> #include <unistd.h> #include <err.h> +#include <errno.h> #include <fcntl.h> int @@ -14,7 +15,7 @@ main(int argc, char *argv[]) char temp[] = "/tmp/dup2XXXXXXXXX"; const char magic[10] = "0123456789"; char c; - int fd; + int fd, ret; if ((fd = mkstemp(temp)) < 0) err(1, "mkstemp"); @@ -44,5 +45,16 @@ main(int argc, char *argv[]) if (c != magic[1]) errx(1, "read2 %c != %c", c, magic[1]); + close(fd); + + /* also, verify that pread fails on ttys */ + fd = open("/dev/tty", O_RDWR); + if (fd < 0) + printf("skipping tty test\n"); + else if ((ret = pread(fd, &c, 1, 7)) != -1) + errx(1, "pread succeeded on tty, returning %d", ret); + else if (errno != ESPIPE) + err(1, "pread"); + return 0; } |