Last active
October 5, 2018 03:58
-
-
Save TheBloke/7108394e7ae3c47c7eb8071a7563539e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fcntl.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define BUFFSIZE 512 | |
#define err(mess) { fprintf(stderr,"Error: %s.", mess); exit(1); } | |
int main() | |
{ | |
int fd, n; | |
char buf[BUFFSIZE]; | |
mkfifo("test_key", 0666); | |
mkfifo("test_key.pub", 0666); | |
if ( (fd = open("test_key", O_RDONLY)) < 0) | |
err("open") | |
while( (n = read(fd, buf, BUFFSIZE) ) > 0) { | |
if ( write(STDOUT_FILENO, buf, n) != n) { | |
exit(1); | |
} | |
} | |
close(fd); | |
if ( (fd = open("test_key.pub", O_RDONLY)) < 0) | |
err("open") | |
while( (n = read(fd, buf, BUFFSIZE) ) > 0) { | |
if ( write(STDOUT_FILENO, buf, n) != n) { | |
exit(1); | |
} | |
} | |
close(fd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Terminal 1:
Terminal 2: