bla
This commit is contained in:
@@ -24,6 +24,8 @@ no-op: no-op.c Makefile
|
||||
get-signal: get-signal.c Makefile
|
||||
gcc -Wall $< -o $@
|
||||
|
||||
fifo: fifo-rx fifo-tx
|
||||
|
||||
dtime.o: dtime.c my-fifo.h Makefile
|
||||
gcc -Wall -c $<
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stddef.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "my-fifo.h"
|
||||
double dtime(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
@@ -13,9 +13,12 @@ int fifo;
|
||||
Message message;
|
||||
double localTS;
|
||||
|
||||
if (argc!=2) exit(1);
|
||||
fifo = mkfifo(argv[1], 0400);
|
||||
if (fifo) {
|
||||
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) {
|
||||
perror("mkfifo fail");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*** named pipe --- transmiter ***/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "my-fifo.h"
|
||||
@@ -15,6 +16,7 @@ if (-1==(fifo = open(argv[1], O_WRONLY))) {
|
||||
perror("open fifo for wr");
|
||||
exit(1);
|
||||
}
|
||||
memset(&message, 0, sizeof(Message));
|
||||
message.pid = getpid();
|
||||
message.timestamp = dtime();
|
||||
write(fifo, &message, sizeof(Message));
|
||||
|
||||
Reference in New Issue
Block a user