24 lines
435 B
C
24 lines
435 B
C
|
/*** 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;
|
||
|
}
|