Thread overview | |||||
---|---|---|---|---|---|
|
October 14, 2016 Missing functionality in std.process? | ||||
---|---|---|---|---|
| ||||
Hi, I developed an application which starts and stops other applications like NodeJS HTTP server applications or Java Tomee Servlets. A typical NodeJS application has a process tree of 4-5 levels. I had to switch really fast from std.process functionality like kill and wait to OS specific functionality because the child processes were not killed entirely leading to effects like blocked ports/files/directories. I have to use windows command taskkill.exe with parameter "Child tree kill". What I miss is s.th. to get the child Pids of a parent Pid. Again I can use OS dependent functionality to retrieve the processIDs of the children, but how to convert these processIDs to Pids for usage with kill/wait functions? Do I miss s.th. fundamental with std.process? Kind regards André |
October 15, 2016 Re: Missing functionality in std.process? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andre Pany | On 15/10/2016 5:33 AM, Andre Pany wrote:
> Hi,
>
> I developed an application which starts and stops other applications
> like NodeJS HTTP server applications or Java Tomee Servlets. A typical
> NodeJS application has a process tree of 4-5 levels.
> I had to switch really fast from std.process functionality like kill and
> wait to OS specific functionality because the child processes were not
> killed entirely leading to effects like blocked ports/files/directories.
> I have to use windows command taskkill.exe with parameter "Child tree
> kill".
>
> What I miss is s.th. to get the child Pids of a parent Pid. Again I can
> use OS dependent functionality to retrieve the processIDs of the
> children, but how to convert these processIDs to Pids for usage with
> kill/wait functions?
>
> Do I miss s.th. fundamental with std.process?
>
> Kind regards
> André
>
Yeah we don't support that right now in std.process.
|
January 06, 2017 Re: Missing functionality in std.process? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andre Pany | On Friday, 14 October 2016 at 16:33:51 UTC, Andre Pany wrote: > What I miss is s.th. to get the child Pids of a parent Pid. Again I can use OS dependent functionality to retrieve the processIDs of the children, but how to convert these processIDs to Pids for usage with kill/wait functions? On Unix you could use core.sys.posix.signal.kill(pid_t, int) core.sys.posix.sys.wait.wait(int*) core.sys.posix.sys.wait.waitpid(pid_t, int*, int) I tested the kill function and it works like a charm. Since pid_t is just an alias to int, just provide the process integer to the function. On Windows, I'm guessing, you could use core.sys.windows.winbase.TerminateProcess(HANDLE, UINT) I don't have a Windows environment set up so you will have to play with this. |
Copyright © 1999-2021 by the D Language Foundation