2021-08-25 07:18:34 +02:00
|
|
|
/*** named pipe --- receiver ***/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/stat.h> /* for mkfifo */
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include "my-fifo.h"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int fifo;
|
|
|
|
Message message;
|
|
|
|
double localTS;
|
|
|
|
|
2021-08-28 17:06:26 +02:00
|
|
|
if (argc!=2) {
|
|
|
|
fprintf(stderr, "%s need a fifo name\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
fifo = mkfifo(argv[1], O_RDONLY|O_CREAT);
|
|
|
|
if (-1==fifo) {
|
2021-08-25 07:18:34 +02:00
|
|
|
perror("mkfifo fail");
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
read(fifo, &message, sizeof(Message));
|
|
|
|
localTS = dtime();
|
|
|
|
printf("%f %f\n", localTS, message.timestamp);
|
|
|
|
close(fifo);
|
|
|
|
return 0;
|
|
|
|
}
|