www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Missing functionality in std.process?

reply Andre Pany <andre s-e-a-p.de> writes:
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é
Oct 14 2016
next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
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.
Oct 14 2016
prev sibling parent Eduard Staniloiu <edi33416 gmail.com> writes:
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.
Jan 06 2017