Execute the Shell command and continue executing the algorithm

Alexander Zhirov azhirov1991 at gmail.com
Mon May 30 11:18:42 UTC 2022


I want to run a command in the background during the execution of 
the algorithm, and without waiting for its actual execution, 
because it is "infinite", while continuing the execution of the 
algorithm and then, knowing the ID of the previously launched 
command, kill the process. So far I have done so:

```d
// Here a long program is launched, as an example `sleep`
executeShell("(sleep 10000 && echo \"SLEEP\" >> log) &");

while (!interrupted)
{
     // some algorithm is executed here, for example `echo`
     executeShell("(echo \"OK\" >> log) &");
     if (here is my condition termination of the program)
     {
         // Here is the termination of the running program
     }
     Thread.sleep(1.seconds);
}
```

How to organize such an algorithm correctly?


More information about the Digitalmars-d-learn mailing list