From: Michael Stapelberg Date: Tue, 21 Feb 2012 12:58:49 +0000 (+0100) Subject: t/166-assign: check for i3-nagbar in the process hierarchy instead of sleep(1) X-Git-Tag: 4.2~58 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=06a9820b5f4b6172aa93758d245daa64dfd74887;p=i3%2Fi3 t/166-assign: check for i3-nagbar in the process hierarchy instead of sleep(1) --- diff --git a/testcases/t/166-assign.t b/testcases/t/166-assign.t index 38797565..8d05c05b 100644 --- a/testcases/t/166-assign.t +++ b/testcases/t/166-assign.t @@ -192,6 +192,22 @@ sleep 0.25; # ticket #501 ##################################################################### +# Walks /proc to figure out whether a child process of $i3pid with the name +# 'i3-nagbar' exists. +sub i3nagbar_running { + my ($i3pid) = @_; + + my @procfiles = grep { m,^/proc/[0-9]+$, } ; + for my $path (@procfiles) { + open(my $fh, '<', "$path/stat") or next; + my $line = <$fh>; + close($fh); + my ($comm, $ppid) = ($line =~ /^[0-9]+ \(([^)]+)\) . ([0-9]+)/); + return 1 if $ppid == $i3pid && $comm eq 'i3-nagbar'; + } + return 0; +} + $config = <