#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include "restart.h"

#define BUFFER_SIZE 1024

int main() {
  int fd;
  char buffer[BUFFER_SIZE];

  if ((fd = open("sampleFIFO", O_RDONLY)) == -1) {
    perror("opening sampleFIFO");
    fprintf(stderr, "Use \"mkfifo sampleFIFO\" to make the FIFO.\n");
    exit(EXIT_FAILURE);
  }

  printf("reading\n");
  fflush(stdout);
  if (r_read(fd, buffer, BUFFER_SIZE) == -1) {
    perror("reading from FIFO");
    exit(EXIT_FAILURE);
  }
  close(fd);
  printf("Read \"%s\"\n", buffer);
  exit(EXIT_SUCCESS);
}
