Re: spawnProcess() not child?

2014-11-03 Thread Bauss via Digitalmars-d-learn

Is there nobody that knows a solution? :(


Re: spawnProcess() not child?

2014-11-03 Thread via Digitalmars-d-learn

On Sunday, 2 November 2014 at 00:59:43 UTC, Bauss wrote:
Is there a way to spawn a process that won't be a child 
process, because I can't seem to kill any processes created 
with spawnProcess() It keeps giving me access denied for the 
processes and it's necessary for me to kill a process, compile 
it and then spawn it again.




Taking a blind guess: Could it be that the process has already 
exited, and the PID got recycled and assigned to a new process? 
Then you would try to kill that process instead of your spawned 
one, which would fail if it doesn't belong to you.


Re: spawnProcess() not child?

2014-11-03 Thread angel via Digitalmars-d-learn

The parent / child relationship always exists.
In POSIX OSs, you may ignore SIGCHLD signal (announcing child 
process death), so that in case of child process exit it will not 
become zombie, rather it will be disposed on the spot.
As a side note, in Linux, there exist a system call allowing 
process re-parenting, but it is intended for use in 
experimenting, rather than in normal use case.
Side note II, there is no real chance of wrapping PID numbers 
around in a reasonable time frame.


Re: spawnProcess() not child?

2014-11-03 Thread Steven Schveighoffer via Digitalmars-d-learn

On 11/3/14 6:34 AM, angel wrote:

The parent / child relationship always exists.
In POSIX OSs, you may ignore SIGCHLD signal (announcing child process
death), so that in case of child process exit it will not become zombie,
rather it will be disposed on the spot.
As a side note, in Linux, there exist a system call allowing process
re-parenting, but it is intended for use in experimenting, rather than
in normal use case.
Side note II, there is no real chance of wrapping PID numbers around in
a reasonable time frame.


From OP's code, he is on Windows.

-Steve


Re: spawnProcess() not child?

2014-11-03 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 3 November 2014 at 14:09:21 UTC, Steven Schveighoffer 
wrote:


From OP's code, he is on Windows.


I believe on Windows you have to sort out some kind of 
permissions to terminate a process.  No idea if std.process does 
this, but it sounds like probably not.


spawnProcess() not child?

2014-11-01 Thread Bauss via Digitalmars-d-learn
Is there a way to spawn a process that won't be a child process, 
because I can't seem to kill any processes created with 
spawnProcess() It keeps giving me access denied for the processes 
and it's necessary for me to kill a process, compile it and then 
spawn it again.


Currently what I do is save the pid of the spawned process and 
then call kill() using that pid then calling dmd which compiles 
it again, but after first compilation and spawning of the process 
I cannot do it again unless I restart the process that's handling 
the compilation etc. so I would like to have the process that 
updates to be a seperate process from the compiled process.


This is my code.
void end() {
if (lastPid)
kill(lastPid);
}

void clear() {
if (exists(processFolder)) {
foreach (string name;
dirEntries(processFolder, SpanMode.depth)) {
remove(name);
}
rmdir(processFolder);
}
}

void compile() {
if (lastPid)
end();
clear();

string[] cmd = [dmd.exe, -of ~ processFile, -m32];
foreach (string e; dirEntries(srcFolder, SpanMode.depth))
cmd ~= e;

auto pid = spawnProcess(cmd);
wait(pid);

lastPid = spawnProcess(processFile);
}

Then I call compile() for everytime I need to update.

I have been looking through various code in the documents and 
google etc. but I cannot seem to achieve what I want. Is there no 
simple way to create a process that isn't associated with any 
processes using spawnProcess?