File: listener.sh

package info (click to toggle)
yorick 1.5.08-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,508 kB
  • ctags: 7,937
  • sloc: ansic: 75,604; cpp: 1,282; lisp: 1,217; sh: 1,026; makefile: 616; fortran: 19
file content (33 lines) | stat: -rwxr-xr-x 840 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

# script to execute shell commands it reads from a named pipe (fifo)
# to create a fifo, use the system utility
#   mkfifo <filename>
# or
#   mknod <filename> -p
# the mknod utility may not be in a standard PATH (try /usr/etc)

# - the purpose of this script is to be able to start commands from
#   a very large program without the need to fork
# - on most modern OSes, fork memory usage may be negligible
# - on some old OSes, using vfork instead of fork solves the problem
# - this script will work on any OS that supports named pipes

input=${1:-$HOME/Yorick/FIFO.0}
output=${2:-$HOME/Yorick/FIFO.1}
case $input in
  -) : ;;
  *) exec <$input ;;
esac
case $output in
  -) : ;;
  *) exec >$output 2>$output ;;
esac

while test 1; do
  echo =-=-listener-=-ready-=-=
  if read line
    then eval $line
    else break
  fi
done