From 06a9820b5f4b6172aa93758d245daa64dfd74887 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 21 Feb 2012 13:58:49 +0100 Subject: [PATCH] t/166-assign: check for i3-nagbar in the process hierarchy instead of sleep(1) --- testcases/t/166-assign.t | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) 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 = <