TetaTricks/code/fifo-rx.c

27 lines
497 B
C
Raw Normal View History

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;
if (argc!=2) exit(1);
fifo = mkfifo(argv[1], 0400);
if (fifo) {
perror("mkfifo fail");
exit(2);
}
read(fifo, &message, sizeof(Message));
localTS = dtime();
printf("%f %f\n", localTS, message.timestamp);
close(fifo);
return 0;
}