FreeBSD/contrib/netbsd-tests/fs/fifofs/t_fifo.c
/*
 * child_writer
 *
 * Function that runs in child context and opens and write to the FIFO.
 */
child_writer
Function that runs in child context and opens and write to the FIFO.
child_writer Function that runs in child context and opens and write to the FIFO .
static void
child_writer(void)
{
	ssize_t rv;
	int fd;
	size_t count;
	char message[MSG_SIZE] = MESSAGE;
	static const struct timespec ts = { 0, 10000 };
	for (;;) {
		fd = open(FIFO_FILE_PATH, O_WRONLY, 0);
		if (fd == -1) {
			if (errno == EINTR)
				continue;
			err(1, "Child: can't open fifo in write mode");
		}
		break;
	}
	for (count = 0; count < NUM_MESSAGES; count++) {
		rv = write(fd, message, MSG_SIZE);
		if (rv == -1) {
			warn("Child: Failed to write");
			break;
		}
		if (rv != MSG_SIZE)
			warnx("Child: wrote only %zd", rv);
		nanosleep(&ts, NULL);
	}
	close(fd);
	if (verbose) {
		printf("Child: Closed the fifo file\n");
		fflush(stdout);
	}
}
static void child_writer ( void ) { ssize_t rv ; int fd ; size_t count ; char message [ MSG_SIZE ] = MESSAGE ; static const struct timespec ts = { 0 , 10000 } ; for ( ; ; ) { fd = open ( FIFO_FILE_PATH , O_WRONLY , 0 ) ; if ( fd == -1 ) { if ( errno == EINTR ) continue ; err ( 1 , " " ) ; } break ; } for ( count = 0 ; count < NUM_MESSAGES ; count ++ ) { rv = write ( fd , message , MSG_SIZE ) ; if ( rv == -1 ) { warn ( " " ) ; break ; } if ( rv != MSG_SIZE ) warnx ( " " , rv ) ; nanosleep ( & ts , NULL ) ; } close ( fd ) ; if ( verbose ) { printf ( " \n " ) ; fflush ( stdout ) ; } }
child_writer
 Function that runs in child context and opens and write to the FIFO.
child_writer Function that runs in child context and opens and write to the FIFO .
/* Open the fifo in write-mode */