"Get the parent process id ?" I found and successfully tested this on Windows 7: http://stackoverflow.com/questions/185254/how-can-a-win32-process-get-the-pi... ULONG_PTR GetParentProcessId() // By Napalm @ NetCore2K{ ULONG_PTR pbi[6]; ULONG ulSize = 0; LONG (WINAPI *NtQueryInformationProcess)(HANDLE ProcessHandle, ULONG ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength); *(FARPROC *)&NtQueryInformationProcess = GetProcAddress(LoadLibraryA("NTDLL.DLL"), "NtQueryInformationProcess"); if(NtQueryInformationProcess){ if(NtQueryInformationProcess(GetCurrentProcess(), 0, &pbi, sizeof(pbi), &ulSize) >= 0 && ulSize == sizeof(pbi)) return pbi[5]; } return (ULONG_PTR)-1;} On Sat, Oct 22, 2016 at 10:38 AM, Klemens Morgenstern < klemens.morgenstern@gmx.net> wrote:
Am 22.10.2016 um 09:17 schrieb Remi Chateauneu:
In boost.process, is there a portable way to: - Kill another process based on the pid ?
Yes, if you have the access rights of course. You can construct a child-object from a pid and see which methods work.
- Get the parent process id ?
There is not. I know there's "getppid" in linux, but there is no similar thing on windows
- Get the list of subprocesses ? Maybe the whole subprocesses tree ?
There is not.
- Be notified when a subprocess crashes ?
Well, when it exits, which includes crashes. You can do that asynchronously with boost.asio.
- Get the current process user id or user name ?
It should not be very difficult to implement because several of these features are already available in some portable Python modules (psutil for example).
I tried to keep to the actual APIs and implement what both platforms provide. There are more things that can be added, especially if one is open to use the "undocumented" api functions on windows.
I'd be happy to talk about additions to the library, but that will happen after the review is done. The API will not change that much anymore, so if you have ideas for additions feel free to work on them and let me know. But keep in mind: they must be on both platforms. The only thing where I accept extensions are the properties - elsewise you can just use the platform-dependent stuff directly:
If the extensions are not needed in the launch-functions, you can just use the stuff directly. I.e.
child c(...); auto parent_id = ::getppid(c.id());
child parent(parent_id); parent.terminate(); //boom.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman /listinfo.cgi/boost