Przeglądaj źródła

fix search for unix binary on MacOS

On MacOS, the `lsof -i :<port>` command seems to show multiple processes
have the port open, one of which is the current Perl program. Since this
one mostly comes first in the output, `shutdown_unix_binary` tries to
kill the `perl` process, not the browser process. Filtering out the
current `perl` process from the process we're trying to kill fixes this
issue.
Doug Bell 6 lat temu
rodzic
commit
47ad6bb657
1 zmienionych plików z 1 dodań i 2 usunięć
  1. 1 2
      lib/Selenium/CanStartBinary.pm

+ 1 - 2
lib/Selenium/CanStartBinary.pm

@@ -423,8 +423,7 @@ sub shutdown_unix_binary {
     my ($self) = @_;
     if (!IS_WIN) {
         my $cmd = "lsof -t -i :".$self->port();
-        my $pid = `$cmd`;
-        chomp $pid;
+        my ( $pid ) = grep { $_ && $_ ne $$ } split /\s+/, scalar `$cmd`;
         if ($pid) {
             print "Killing Driver PID $pid listening on port ".$self->port."...\n";
             eval { kill 'KILL', $pid };