lib/Tools/mkfifo
author blanchet
Wed, 01 Sep 2010 00:03:15 +0200
changeset 38990 7fba3ccc755a
parent 38253 3d4e521014f7
child 39520 bad14b7d0520
permissions -rwxr-xr-x
finish moving file

#!/usr/bin/env bash
#
# Author: Makarius
#
# DESCRIPTION: create named pipe


PRG="$(basename "$0")"

function usage()
{
  echo
  echo "Usage: isabelle $PRG"
  echo
  echo "  Create a temporary named pipe and return its name."
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


## main

[ "$#" != 0 ] && usage

#FIXME potential race condition wrt. future processes with same pid
FIFO="/tmp/isabelle-fifo$$"

mkfifo -m 600 "$FIFO" || fail "Failed to create fifo: $FIFO"
echo "$FIFO"