hcienginestop on 5.7 never SIGINT or SIGKILL anymore

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf hcienginestop on 5.7 never SIGINT or SIGKILL anymore

  • Creator
    Topic
  • #51670
    frans de Wet
    Participant

      Found a bug where the push statement is misplaced in an else (instead of being in the if) in the hcienginestop command on Linux (may be other platforms too) on Cloverleaf 5.7.  Rev 2 does not fix it.  

      In the hcienginestop command in $HCIROOT/bin replace the stopProcess subroutine with this:

      Code:


      ######################################################################
      # stopProcess – Stop the engine using progressively meaner tactics
      #
      sub stopProcess {
         local( $pid );
         local( @procs) = ();
         local( $flag) = 0;
         local( $proc_len);

         $proc_len = @opt_proc;

         foreach $p (@opt_proc) {

      if ($proc_len > 1) {
         print “Stopping process $p n”;
      }

      if( ($pid = &getHciEnginePid( $p )) == 0 ) {
         print “Process ‘$p’ is not runningn”;
         next;
      }

      # First try sending it a “die” command
      print “Trying hcicmd…n”;
      if ($onNT) {
         if( system( “hcicmdnt.exe -p $p -c “. die”” ) ) {
      printf STDERR “hcicmd failed!nn”;
      push(@procs,$p);
         }
      } else {
         if( system( “hcicmd -p $p -c “. die”” ) ) {
      printf STDERR “hcicmd failed!nn”;
      push(@procs,$p);
         }
      }
         }

         if (( $len = @procs ) != 0) {
      @opt_proc = @procs;

      # Give it time to die
      $flag = &waitForAll();
         } else {
      $flag = 0;
         }

         #For flag, the true means there are some processes which are still  running
         if ( $flag ) {
      #There are some processes which are still running

             # On Windows, try SIGKILL
      if ( $onNT ) {
         foreach $opt_p (@opt_proc) {
      $PidFile = “$Pwdir/$opt_p/pid”;
      print “Now trying SIGKILL…n”;
      kill( ‘KILL’, $pid );
      unlink( $PidFile ); # remove the pid file
      print “Process ‘$opt_p’ is not runningn”;
         }
         return 1;
      }

      # On NUIX, try SIGINT first
      foreach $opt_p (@opt_proc) {
         # Now try SIGINT
         print “Now trying SIGINT…n”;
         if( kill( ‘INT’, $pid ) == 0 ) {
      print STDERR “Unable to send SIGINT: $!n”;
         }
      }
      if (&waitForAll()) {
         #There are some processes which are still running
         #Try SIGKILL then
         foreach $opt_p (@opt_proc) {
      # Now try SIGKILL
      print “Now trying SIGKILL…n”;
      if( kill( ‘KILL’, $pid ) == 0 ) {
         print STDERR “Unable to send SIGKILL: $!n”;
      }
         }
         
         if (&waitForAll()) {
      #There are some processes which can not be killed
      foreach $opt_p (@opt_proc) {
         print “nUnable to stop process ‘$opt_p’!n”;
      }

      return 0;
         }
      }
         }

         if ($proc_len > 1) {
      #All processes are not running
      print “All Processes are not runningn”;
         }
         return 1;
      }

      Thanks,

      Frans

    • The forum ‘Cloverleaf’ is closed to new topics and replies.