commit 10363565a1708a5a5adb6e6624de0dde6455ded4
parent 7b147cb0c1eaa728f244cc8390ccfcc3f4aee03a
Author: Mattias Andrée <maandree@kth.se>
Date: Thu, 25 May 2017 18:22:39 +0200
Document blind-to-named and blind-from-named
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat:
5 files changed, 118 insertions(+), 3 deletions(-)
diff --git a/README b/README
@@ -48,6 +48,9 @@ UTILITIES
blind-from-image(1)
Convert an image to a frame
+ blind-from-named(1)
+ Receive a file descriptor
+
blind-from-portable(1)
Convert a video from a portable format to a processable format
@@ -117,6 +120,9 @@ UTILITIES
blind-to-image(1)
Convert a frame to an image
+ blind-to-named(1)
+ Send a file descriptor
+
blind-to-portable(1)
Convert a video to a portable format
diff --git a/man/blind-from-named.1 b/man/blind-from-named.1
@@ -0,0 +1,64 @@
+.TH BLIND-FROM-NAMED 1 blind
+.SH NAME
+blind-from-named - Receive a file descriptor
+.SH SYNOPSIS
+.B blind-from-named
+[-t
+.IR decisecs ]
+[-a]
+([-f
+.IR fd ]
+.I path
+.RI [ command \ ...]
+|
+.IR path )
+.SH DESCRIPTION
+.B blind-from-named
+connects to a
+.BR unix (7)
+socket with the filename
+.I path
+and received a file descriptor.
+.P
+If a
+.I command
+is specified, the received file descriptor set to
+stdin, and the process executes to the specified
+.IR commmand ,
+otherwise, the input from the received file descriptor
+is sent to stdout.
+.SH OPTIONS
+.TP
+.B -a
+Rather than binding to a filename, create and abstract
+address, starting with a NUL byte followed by
+.I path
+and padded with NUL bytes until the end of the address.
+.TP
+.BR -f \ \fIfd\fP
+Assign the file descriptor number
+.I fd
+to the received file descriptor, rather than as
+stdin.
+.TP
+.BR -t \ \fIdecisecs\fP
+Try to connect to the socket for at most
+.I decisecs
+deciseconds, trying once per decisecond. (Default is 10.)
+.SH RATIONALE
+The pipeline construction, in even advanced, shells
+are not flexible enough to do all kinds of pipelinings
+that are necessary when doing complicated effects with
+.BR blind (7).
+For example, this is necessary to pipe video into
+two processes pipelines using
+.BR tee (1)
+and then using the end of both pipelines as the in
+input to the process, like inverse multiplexing.
+.SH SEE ALSO
+.BR blind (7),
+.BR blind-to-named (1),
+.BR tee (1)
+.SH AUTHORS
+Mattias Andrée
+.RI < maandree@kth.se >
diff --git a/man/blind-to-named.1 b/man/blind-to-named.1
@@ -0,0 +1,39 @@
+.TH BLIND-TO-NAMED 1 blind
+.SH NAME
+blind-to-named - Send a file descriptor
+.SH SYNOPSIS
+.B blind-to-named
+[-a]
+.I path
+.SH DESCRIPTION
+.B blind-to-named
+create a
+.BR unix (7)
+socket with the filename
+.I path
+and sends the stdin file descriptor to the
+first process that connects to it.
+.SH OPTIONS
+.TP
+.B -a
+Rather than binding to a filename, create and abstract
+address, starting with a NUL byte followed by
+.I path
+and padded with NUL bytes until the end of the address.
+.SH RATIONALE
+The pipeline construction, in even advanced, shells
+are not flexible enough to do all kinds of pipelinings
+that are necessary when doing complicated effects with
+.BR blind (7).
+For example, this is necessary to pipe video into
+two processes pipelines using
+.BR tee (1)
+and then using the end of both pipelines as the in
+input to the process, like inverse multiplexing.
+.SH SEE ALSO
+.BR blind (7),
+.BR blind-from-named (1),
+.BR tee (1)
+.SH AUTHORS
+Mattias Andrée
+.RI < maandree@kth.se >
diff --git a/man/blind.7 b/man/blind.7
@@ -61,6 +61,9 @@ Mirror a video horizontally
.BR blind-from-image (1)
Convert an image to a frame
.TP
+.BR blind-from-named (1)
+Receive a file descriptor
+.TP
.BR blind-from-portable (1)
Convert a video from a portable format to a processable format
.TP
@@ -130,6 +133,9 @@ Draw new frames on top of old frames with partial alpha
.BR blind-to-image (1)
Convert a frame to an image
.TP
+.BR blind-to-named (1)
+Send a file descriptor
+.TP
.BR blind-to-portable (1)
Convert a video to a portable format
.TP
diff --git a/src/blind-from-named.c b/src/blind-from-named.c
@@ -76,7 +76,7 @@ main(int argc, char *argv[])
struct sockaddr_un addr;
int abstract = 0;
int filedes = -1;
- int tries = 10;
+ int tries = 11;
int sockfd, fd;
ARGBEGIN {
@@ -87,7 +87,7 @@ main(int argc, char *argv[])
filedes = etoi_flag('f', UARGF(), 0, INT_MAX);
break;
case 't':
- tries = etoi_flag('t', UARGF(), 1, INT_MAX);
+ tries = etoi_flag('t', UARGF(), 0, INT_MAX - 1) + 1;
break;
default:
usage();
@@ -95,7 +95,7 @@ main(int argc, char *argv[])
if (argc < 1 || (filedes >= 0 && argc > 1))
usage();
if (argc > 0 && filedes < 0)
- filedes = 0;
+ filedes = STDIN_FILENO;
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;