OS 10.1 replacement for the "killall" command?

Ken Ray kray at sonsothunder.com
Sun Feb 2 21:26:01 EST 2003


Here's what I've done: You can get a list of the processes in long form
using "ps -axw -o pid,command", which will give you a list of file paths for
each file along with its process ID. You can then kill it using "kill -9".
Here's the functions I use:

function GetPID pAppName
  -- Note: Requires applications to be within the first 132 characters of
the path name
  if char -4 to -1 of pAppName <> ".app" then
    put ".app" after pAppName  -- just in case
  end if
  put shell("ps -axw -o pid,command") into tProcList
  put lineOffset("/" & pAppName & "/",tProcList) into tLine
  if tLine <> 0 then
    return (word 1 of line tLine of tProcList)
  else
    return 0
  end if
end GetPID

on KillProcess pPID
  if pPID <> 0 then
    get shell("kill -9 " & pPID)
  else
    return "Process not found."
  end if
end KillProcess

And then I call it like this:

on mouseUp
  KillProcess (GetPID("MyApp.app"))
  if the result <> "" then
    answer "Error: " & the result
  else
    -- rest of my code here
  end if
end mouseUp

Hope this helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


----- Original Message -----
From: <RGould8 at aol.com>
To: <use-revolution at lists.runrev.com>
Sent: Sunday, February 02, 2003 6:45 PM
Subject: OS 10.1 replacement for the "killall" command?


> I have a Revolution app that makes a call to Unix in Mac OS 10.2 to do a
> "killall <badprocessname>".  Is there a Mac OS 10.1 equivilant?  I was
> thinking it might be some combo of doing a "ps" to find the process id,
and
> then the "kill" statement to kill it off, but I haven't had success with
the
> ps command (I only get 1 process listed, even if I see 20 processes listed
in
> the OS X "Process Viewer" utility.)
>




More information about the use-livecode mailing list