check for running process
    Steven Schveighoffer 
    schveiguy at yahoo.com
       
    Wed Oct  5 08:05:02 PDT 2011
    
    
  
On Wed, 05 Oct 2011 10:38:58 -0400, Dsmith <Dsmith at nomail.com> wrote:
> In the core.thread library, there is a method isRunning() which takes a  
> thread.
>
> To make code more portable, rather than use a system call or getenv(),  
> how might
> isRunning() be adapted to check if a program is running?
> Ideally: isrunning(program_name);
It cannot.  isRunning checks a local boolean, it does not do any OS  
queries.
Now, once you have a reference to a running process, I'd say it's probably  
possible to add isRunning methods that call on the OS functions.  Given a  
process ID, getting information about the process is pretty  
straightforward.  I think this might be a good addition to std.process if  
it's not already in there.
It's just the getting of the pid based on the name is not straightforward.
-Steve
    
    
More information about the Digitalmars-d-learn
mailing list