]> git.sur5r.net Git - i3/i3/commitdiff
tests: re-seed random number generator in workers
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 10 Sep 2017 17:41:49 +0000 (19:41 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 10 Sep 2017 19:03:13 +0000 (21:03 +0200)
testcases/lib/TestWorker.pm

index aee994f74115a8defe0e435e7f2bdbf26cb61cd5..c56767c4172fec49279cd0c6a55dc153fed69ecc 100644 (file)
@@ -99,6 +99,11 @@ sub worker_wait {
 
             $0 = $file;
 
+            # Re-seed rand() so that File::Temp’s tempnam produces different
+            # results, making a TOCTOU between e.g. t/175-startup-notification.t
+            # and t/180-fd-leaks.t less likely.
+            srand(time ^ $$);
+
             POSIX::dup2($ipc_fd, 0);
             POSIX::dup2($ipc_fd, 1);
             POSIX::dup2(1, 2);