select?? that's for sockets... bleh
Use a fifo !
something simple like
Code:
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#define FIFO_NAME "/tmp/tha_fifo_stuff"
int main(){
int cpid, fd;
char msg[1000] = "";
mkfifo(FIFO_NAME,S_IRWXU);
switch(cpid = fork()){
case -1:perror("fork()");
return 0;
case 0: //child
fd = open(FIFO_NAME,O_WRONLY|O_NONBLOCK);
strcpy(msg,"hello daddy");
write(fd,msg,strlen(msg)+1);
close(fd);
return 0;
default:
wait(&cpid);
fd = open(FIFO_NAME,O_RDONLY);
read(fd,msg,999);
printf("my son with pid %d sayd: '%s'\n",cpid,msg);
close(fd);
}
unlink(FIFO_NAME);
return 0;
}