TetaTricks/code/fifo-tx.c

26 lines
495 B
C
Raw Normal View History

2021-08-25 07:18:34 +02:00
/*** named pipe --- transmiter ***/
#include <stdio.h>
#include <stdlib.h>
2021-08-28 17:06:26 +02:00
#include <string.h>
2021-08-25 07:18:34 +02:00
#include <unistd.h>
#include <fcntl.h>
#include "my-fifo.h"
int main(int argc, char *argv[])
{
int fifo;
Message message;
if (argc!=2) exit(1);
if (-1==(fifo = open(argv[1], O_WRONLY))) {
perror("open fifo for wr");
exit(1);
}
2021-08-28 17:06:26 +02:00
memset(&message, 0, sizeof(Message));
2021-08-25 07:18:34 +02:00
message.pid = getpid();
message.timestamp = dtime();
write(fifo, &message, sizeof(Message));
close(fifo);
return 0;
}