I'm studying Operating System and this code has been written but i'm having difficulty figuring out what each of these snippets do?
What would be the Outputs of each of the following code snippets and why?
1. if ((mknod (FIFO1, S_IFIFO | PERMS, 0) < 0) && (errno != EEXIST))
{
perror ("mknod FIFO1");
exit (1);
}
2. if (mkfifo(FIFO2, PERMS) < 0)
{
unlink (FIFO1);
perror("mknod FIFO2");
exit (1);
}
3. if ((readfd = open(FIFO1, 0)) < 0)
{
perror ("open FIFO1");
exit (1);
}
4. if ((writefd = open(FIFO2, 1)) < 0)
{
perror ("open FIFO2");
exit (1);
}
5. size = strlen(MESSAGE1) + 1;
if ((n = read(readfd, buff, size)) < 0) {
perror ("server read"); exit (1);
}
6. size = strlen(MESSAGE1) + 1;
if (write(writefd, MESSAGE1, size) != size)
{
perror ("client write1"); exit (1);
}