Execute the Shell command and continue executing the algorithm
Christian Köstlin
christian.koestlin at gmail.com
Tue May 31 12:30:56 UTC 2022
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
>
More information about the Digitalmars-d-learn
mailing list