On 2022-05-30 15:25, Ali Çehreli wrote:
On 5/30/22 04:18, Alexander Zhirov wrote:

 > I want to run a command in the background

The closest is spawnShell:

import std.stdio;
import std.process;
import core.thread;

void main() {
   auto pid = spawnShell(`(sleep 10000 & echo SLEEP >> log)`);
   Thread.sleep(5.seconds);
   kill(pid);
   writeln("Terminated with ", wait(pid));
}

I am not good at shell scripting but I had to change your && to & to see anything in log.
I think this runs sleep 10000 in the background and emits the echo directly.

As std.process documentation explains, the value returned by wait() (and more) are platform dependent.

Ali


Reply via email to