- /* Slave cases. Read one byte from fd 0, and write its value
- plus one to fd 1. fd 2 should be closed iff the argument is
- 9. Check that no other fd's leaked. */
- case 8:
- case 9:
- {
- char buffer[1];
- ASSERT (read (STDIN_FILENO, buffer, 1) == 1);
- buffer[0]++;
- ASSERT (write (STDOUT_FILENO, buffer, 1) == 1);
- errno = 0;
- i = fcntl (STDERR_FILENO, F_GETFL);
- if (test == 8)
- ASSERT (0 <= i);
- else
- {
- ASSERT (i < 0);
- ASSERT (errno == EBADF);
- }
- for (i = 3; i < 7; i++)
- {
- errno = 0;
- ASSERT (close (i) == -1);
- ASSERT (errno == EBADF);
- }
- return 0;
- }
- default:
- ASSERT (0);
- }
- /* All remaining code is for the driver. Plug any leaks inherited
- from outside world before starting, so that child has a clean
- slate (at least for the fds that we might be manipulating). */
- for (i = 3; i < 7; i++)
- close (i);
- test_pipe (argv[0], 3 < test);