Hey,

it's actually extremely simple. Feel free to use the following code if it helps you:

bool Process::isRunning(pid_t pID) {
    if (pID <= 0) {
        return false;
    }
#if defined(PLATFORM_ENVIRONMENT_WIN32)
    HANDLE handle = OpenProcess(SYNCHRONIZE, false, pID);
    if (!handle) {
        return false;
    } else {
        CloseHandle(handle);
        return true;
    }
#elif defined(PLATFORM_ENVIRONMENT_UNIX)
    if (kill(pID, 0) == -1) {
        return false;
    } else {
        return true;
    }
#endif
}

Just keep in mind that zombie pids will be reported as running.

On 7 September 2010 23:59, Allen Cronce <allenslists@gmail.com> wrote:
Hi Boris,

Thanks for getting back to me. We're currently using boost::process 0.31. I wasn't aware of 0.4, or any recent activity in boost::process. I'll keep that in mind the next time I have boost::process questions.

As far as the create_snapshot proposal is concerned, that looks interesting.

Unfortunately I need a solution very soon, so my guess is that I'll have to roll my own this time.

Best,
--
Allen Cronce

On Sep 6, 2010, at 1:54 PM, Boris Schaeling wrote:

> On Mon, 06 Sep 2010 21:09:33 +0200, Allen Cronce <allenslists@gmail.com> wrote:
>
>> [...]I can see that boost::process supports obtaining a process ID. The question is can boost::process use this ID to determine if a given process, which was not launched as a child, is still running?
>
> I assume you refer to Boost.Process 0.4 which has been released recently and is currently heavily discussed on the Boost developer's list.
>
> There is a proposal at <http://www.highscore.de/boost/gsoc2010/process/appendices.html> how to create a snapshot of currently running processes. The function create_snapshot() wasn't finished in time though to ship it with 0.4. There were some more ideas to filter processes returned by create_snapshot() (eg. if you are only interested in processes owned by a certain user). But I think in general this kind of function could help you? You could then either iterate through the processes in the snapshot or filter with the process ID directly?
>
> Boris
>
> _______________________________________________
> Boost-users mailing list
> Boost-users@lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users