bad_lseek - /* * lseek */ #include #include #include...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * lseek */ #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <err.h> #include "config.h" #include "test.h" static void lseek_fd_device(void) { int fd, rv; fd = open("null:", O_RDONLY); if (fd<0) { warn("UH-OH: opening null: failed"); return; } rv = lseek(fd, 309, SEEK_SET); report_test(rv, errno, ESPIPE, "lseek on device"); close(fd); } static void lseek_file_stdin(void) { int fd, fd2, rv, status; const char slogan[] = "There ain't no such thing as a free lunch"; size_t len = strlen(slogan); pid_t pid; /* fork so we don't affect our own stdin */ pid = fork(); if (pid<0) { warn("UH-OH: fork failed"); return; } else if (pid!=0) { /* parent */ rv = waitpid(pid, &status, 0); if (rv<0) { warn("UH-OH: waitpid failed"); } if (status!=0) { warn("UH-OH: subprocess exited with code %d", status); } return;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
} /* child */ fd = open_testfile(NULL); if (fd<0) { _exit(0); } /* * Move file to stdin. * Use stdin (rather than stdout or stderr) to maximize the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/10/2009 for the course CS 536 taught by Professor Lums during the Spring '09 term at Indiana.

Page1 / 4

bad_lseek - /* * lseek */ #include #include #include...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online