Re: How to read live output from another process ?

2023-06-28 Thread Vinod K Chandran via Digitalmars-d-learn

On Friday, 23 June 2023 at 23:37:29 UTC, Vinod K Chandran wrote:

Hi all,


Hi, I found the solution by myself. We can use Pipe struct for 
this job.

Here is the code looks like. This is for future readers.

```d
void onBtnBurnClick(Control c, EventArgs e) { // A button click 
event handler

if (!jobStarted) {
jobStarted = true;
btnBurn.text = "Stop the job";
string cmd = makeCommand();
ff = spawn(, cmd); // ff is global var
} else {
ff.send(-1); // Send a signal to stop the job
btnBurn.text = "Start the job";
}
}

void runInAnotherThread(string cmd) {
Duration du = dur!"hnsecs"(-2); // Minus value for no waiting
auto psin = pipe();
auto psout = pipe();
auto pserr = pipe();
	spawnShell(cmd, psin.readEnd, psout.writeEnd, pserr.writeEnd , 
null, Config.detached);

string line;
while ((line = pserr.readEnd.readln()) !is null){
		receiveTimeout(du, (int dummy) {psin.writeEnd.writeln("q"); 
psin.writeEnd.flush(); }); // Here, entering "q" is app specific 
command to stop.

writefln("pipe err: %s", line);
stdout.flush;
}
}
```
By this way, you can asynchronously process the output from the 
child process.


Re: Strange behaviour of __traits(allMembers)

2023-06-28 Thread Dennis via Digitalmars-d-learn

On Sunday, 18 June 2023 at 10:21:16 UTC, IchorDev wrote:
Whaat why has this not been fixed in the 
last 4 years!


It's now fixed: https://github.com/dlang/dmd/pull/15335