hi my friend gave me some code and when comiling i get errors. The code contains fifo and i dont really have any idea about fifo and well i cant find any good tutorials/reading material about fifo i dont suppose anyone could tell me what i need to add to get this code working or link me to some stuff so i can learn fifo.
Code:#include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int myfork(); int main(void) { myfork(); } int myfork(void) { int random, pipePrioity[2], pipePID[2]; pid_t pid; printf("Child Process Being Created...please wait...\n"); sleep(2); pid = fork(); if (pid == 0) { printf("\nChild Prioity = %d", random); printf("\nChild PID = %d\n\n", getpid()); char printTemp[10]; sprintf(printTemp, "%i", random); write(pipePrioity[1], printTemp, 5); sprintf(printTemp, "%i", getpid()); write(pipePID[1], printTemp, 5); } else if (pid > 0) { int myfifoNum; int fifoint2; char fifochar1[80]; sprintf( fifochar1, "%d|%d", random, getpid() ); fifoint2 = open(FIFO_NAME, O_WRONLY); if ((myfifoNum = write(fifoint2, fifochar1, strlen(fifochar1))) == -1) { perror("write"); printf("\nERROR WRITING TO PIPE\n"); } else { printf("\nPrint Job Sent to the Killer (DeSpooler)."); } close(FIFO_NAME); } else { perror("myfork"); printf("Error Creating Print Job. Print Job Not Created"); exit(1); }
output:
i understand that i need to define a fifo name and stuff but i dont know howCode:C:\Users\TraV\Desktop\c programming\meow2.c||In function `int myfork()':| C:\Users\TraV\Desktop\c programming\meow2.c|46|error: `FIFO_NAME' was not declared in this scope| C:\Users\TraV\Desktop\c programming\meow2.c|46|error: `O_WRONLY' was not declared in this scope| ||=== Build finished: 6 errors, 0 warnings ===|



LinkBack URL
About LinkBacks





Probably the last aspect to deal with in your complete program.