summaryrefslogtreecommitdiffstats
path: root/debian/building-in-ci.sh
blob: ccf552d0e88274c836a7651bd020f8449faf36fc (plain)
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
#!/bin/bash

# this script prints 'true' if any ancestor process name is any of $REGEXPS

REGEXPS="debci autopkgtest adt"

set -e

walk()
{
	pid=$1

	[ ! -r /proc/$pid/cmdline ] && exit 1

	name=$(ps -p $pid -o cmd | tail -1)
	for exp in $REGEXPS
	do
		if grep -e $exp <<< $name >/dev/null ; then
			echo true
			exit
		fi
	done

	ppid=$(ps -o ppid= $pid | tr -d ' ')
	walk $ppid
}

walk $$