lib/Tools/mkfifo
author wenzelm
Fri, 29 Aug 2008 20:36:05 +0200
changeset 28061 5428435de53e
parent 28047 8dcf4349cf6f
child 28650 a7ba12e0d3b7
permissions -rwxr-xr-x
use hardwired /tmp -- fifo only work on local file-system;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28047
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     2
#
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     3
# $Id$
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     4
# Author: Makarius
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     5
#
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     6
# DESCRIPTION: create named pipe
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     7
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     8
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     9
PRG="$(basename "$0")"
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    10
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    11
function usage()
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    12
{
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    13
  echo
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    14
  echo "Usage: $PRG"
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    15
  echo
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    16
  echo "  Create a temporary named pipe and return its name."
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    17
  echo
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    18
  exit 1
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    19
}
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    20
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    21
function fail()
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    22
{
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    23
  echo "$1" >&2
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    24
  exit 2
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    25
}
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    26
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    27
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    28
## main
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    29
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    30
[ "$#" != 0 ] && usage
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    31
28061
5428435de53e use hardwired /tmp -- fifo only work on local file-system;
wenzelm
parents: 28047
diff changeset
    32
FIFO="/tmp/isabelle-fifo$$"
28047
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    33
mkfifo -m 600 "$FIFO" || fail "Failed to create named pipe $FIFO"
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    34
echo "$FIFO"