File: btest-bg-run

package info (click to toggle)
btest 0.72-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,208 kB
  • sloc: python: 2,187; sh: 547; makefile: 165; xml: 12; awk: 1
file content (36 lines) | stat: -rwxr-xr-x 708 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
34
35
36
#! /usr/bin/env bash
#
# Usage: btest-bg-run <tag> <cmdline>
#
# Creates a new empty working directory <tag> within the current directory
# and spawns <cmdline> in there in the background. It also records
# a set of meta information that btest-bg-wait will read.

if [ "$#" -le 1 ]; then
    echo "usage: $(basename "$0") <tag> <cmdline>"
    exit 1
fi

cwd=$(pwd)
cd "$(dirname "$0")" || exit 1
helper=$(pwd)/btest-bg-run-helper
setsid=$(pwd)/btest-setsid
cd "$cwd" || exit 1

dir=$1
shift

if [ -e "$dir" ]; then
    echo "directory '$dir' already exists" >&2
    exit 1
fi

echo "$dir" >>.bgprocs
mkdir "$dir"
cd "$dir" || exit 1

echo "$@" >.cmdline

$setsid "$helper" "$@" >.stdout 2>.stderr &

sleep 1