TetaTricks/code/fifo-tx.c

24 lines
435 B
C
Raw Normal View History

2021-08-25 16:18:34 +11:00
/*** named pipe --- transmiter ***/
#include <stdio.h>
#include <stdlib.h>
#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);
}
message.pid = getpid();
message.timestamp = dtime();
write(fifo, &message, sizeof(Message));
close(fifo);
return 0;
}