lib/Tools/mkfifo
author paulson
Tue, 02 Feb 2010 09:48:20 +0000
changeset 35503 7bba12c3b7b6
parent 29143 72c960b2b83e
child 38253 3d4e521014f7
permissions -rwxr-xr-x
Correction of a tiny error
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
# Author: Makarius
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     4
#
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     5
# DESCRIPTION: create named pipe
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     6
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     7
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     8
PRG="$(basename "$0")"
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
     9
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    10
function usage()
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    11
{
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    12
  echo
28650
a7ba12e0d3b7 tuned usage line;
wenzelm
parents: 28061
diff changeset
    13
  echo "Usage: isabelle $PRG"
28047
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    14
  echo
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    15
  echo "  Create a temporary named pipe and return its name."
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    16
  echo
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    17
  exit 1
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    18
}
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    19
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    20
function fail()
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    21
{
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    22
  echo "$1" >&2
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    23
  exit 2
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    24
}
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
## main
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    28
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    29
[ "$#" != 0 ] && usage
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    30
28061
5428435de53e use hardwired /tmp -- fifo only work on local file-system;
wenzelm
parents: 28047
diff changeset
    31
FIFO="/tmp/isabelle-fifo$$"
28047
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    32
mkfifo -m 600 "$FIFO" || fail "Failed to create named pipe $FIFO"
8dcf4349cf6f create named pipe;
wenzelm
parents:
diff changeset
    33
echo "$FIFO"