omg i need help so bad. I've been working on a school project for what seems like an eternity and i'm close to deadline. Using FIFO's (i ahve to) to communicate between parent and child proc's. Right now I'm stuck on a read/write.
fifomsg is a struct with int length and char[16] message fields. This is what I'm trying to send between the processes.
child code:
fdw = Open("syscallfifo", O_WRONLY);
fifomsg msg1;
strcpy(msg1.message, (char*)pid);
msg1.length = sizeof(msg1);
write(fdw, &msg1, sizeof(msg1));
close(fdw);
parent code:
fdr = Open("syscallfifo", O_RDWR);
fifomsg msg1;
read(fdr, &msg1.length, sizeof(msg1.length));
read(fdr, &msg1.message, sizeof(msg1) - sizeof(msg1.length));
close(fdr);
At this point in execution, the process halts and I have to suspend/kill. I'm begging for help. As soon as possible would be ideal.
If I can't get the struct data to work, I'm going to have to resort to a fixed-sized character array to pass to the FIFO. I'm working on this as a backup because I can't progress any further with my msg struct. I'm getting a freeze when I use strcat.
int MSGSIZE = 16;
char* msgbuf;
msgbuf = (char*)malloc(MSGSIZE+1);
sprintf(msgbuf, "systemcall");
strcat(msgbuf, (char*)pid);
int fdw = Open("syscallfifo", O_WRONLY);
int written = write(fdw, msgbuf, sizeof(msgbuf));
I'm desperate. Thank anyone for any consideration.
also I wanted to mention I searched through the forum and couldn't find a similar problem.