File: trun

package info (click to toggle)
lapack 3.2.1-8
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 55,196 kB
  • ctags: 33,064
  • sloc: fortran: 448,214; perl: 8,226; makefile: 1,528; sh: 87; awk: 70
file content (42 lines) | stat: -rw-r--r-- 606 bytes parent folder | download | duplicates (6)
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
34
35
36
37
38
39
40
41
42
#!/bin/bash

T=$1
shift

rm -f foo
mkfifo foo

#eval $1 <&0 >foo  &
$1 <&0 >foo 2>&1 &
j=$!
sleep 1 && tail -f foo --pid=$j &

while true ; do 
#    [ -e foo ] || break;
    touch foo1 -t $(date +%Y%m%d%H%M.%S -d "$T seconds ago")
    [ foo -ot foo1 ] && kill -15 $j >/dev/null 2>&1 && break
    sleep 1
done &
k=$!

wait $j
l=$?

sleep 2

#cat foo
if ! kill $k >/dev/null 2>&1 ; then

	echo $@ failed to terminate after $T seconds

else

	if [ $l -ge 128 ] ; then l=$(($l-128)); fi
	if [ $l -ne 0 ] ; then s="failed" ; else s="exited"; fi
	echo $@ $s with status $l $(kill -l $l)

fi

rm foo foo1

exit 0