Script ends abruptly with a Terminated message

1,038

When you are calling pkill -f resque it is also matching your script, sending it a SIGTERM. If you are unable to add additional restrictions on the pkill commands such as more exact matching, you will need to kill PIDs one at a time to ensure the script is not killing itself. Here is an example:

pids=( $(pgrep -f resque) )
for pid in "${pids[@]}"; do
  if [[ $pid != $$ ]]; then
    kill "$pid"
  fi
done
Share:
1,038

Related videos on Youtube

David
Author by

David

Updated on September 18, 2022

Comments

  • David
    David over 1 year

    I am running the following javascript:

    $('img').each(
        function(){
            var w = parseInt(this.width);
                alert(w);
                alert(this.src);
            if(w > 300){
    
                var percent = parseInt((w/666)*100);
                $(this).removeAttr('width height').css('width',percent + "%");
    
            }
    });
    

    And I am getting the following error:

    Error: uncaught exception: [Exception... "String contains an invalid character" code: "5" nsresult: "0x80530005 (NS_ERROR_DOM_INVALID_CHARACTER_ERR)" location: "http://code.jquery.com/jquery-1.6.4.min.js Line: 2"]

    I'm having trouble actually trying to track this one down as it isn't very descriptive of the problem or the source of the problem. Can anyone shed some light on the problem?

    Thanks

    • Platinum Azure
      Platinum Azure about 12 years
      Why are you using escaped quotes? Use $('img').each(/*...*/);
    • Rodaine
      Rodaine about 12 years
      Are the escapes (\) in your actual code?
    • Jasper
      Jasper about 12 years
      That's a pretty accurate error code :) -- String contains an invalid character.
    • Hersheezy
      Hersheezy about 12 years
      This is a lot of code for a simple bug. I would recommend trying to narrow down where in the code the problem occurs by removing lines until you find the one that it is on. Might even find the solution yourself before having to post it :)
    • David
      David about 12 years
      stupid me, ignore the escapes, thats because they are in a php string. They aren't actually done when the document is printed.
    • jordanm
      jordanm over 10 years
      I provided an answer to the question, but I also want to note that the script is broken by design. See: mywiki.wooledge.org/ProcessManagement
    • theTuxRacer
      theTuxRacer over 10 years
      Thank you. I am taking a look at it, especially the process killing part.
    • ChuckCottrill
      ChuckCottrill over 10 years
      Please provide the name of the script when you are using ps :-)
  • ChuckCottrill
    ChuckCottrill over 10 years
    mypid=$$; pids=($(pgrep -f resque|grep -v $mypid))