Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 05, 2011 check for running process | ||||
---|---|---|---|---|
| ||||
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); |
October 05, 2011 Re: check for running process | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dsmith | On Wed, 05 Oct 2011 10:38:58 -0400, Dsmith <Dsmith@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
|
October 05, 2011 Re: check for running process | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Wed, 05 Oct 2011 16:05:02 +0100, Steven Schveighoffer <schveiguy@yahoo.com> wrote: > On Wed, 05 Oct 2011 10:38:58 -0400, Dsmith <Dsmith@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. .. on unix systems. :p In the past I've had to parse "ps" output on various platforms. On Windows it's a great deal easier. -- Using Opera's revolutionary email client: http://www.opera.com/mail/ |
October 05, 2011 Re: check for running process | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | Steven Schveighoffer Wrote: > It's just the getting of the pid based on the name is not straightforward. There's an open standard for this: http://en.wikipedia.org/wiki/Common_Information_Model_%28computing%29 |
Copyright © 1999-2021 by the D Language Foundation