www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Implementing a watchdog process for a console program

So I'm implementing a watchdog process for my web server, or a 
deadman switch as it's called here: 

But I ran into a problem with filtering watchdog kicks and then 
forwarding other I/O through the watchdog process. Here's what I 
have done so far:

import std.experimental.all;
immutable watchdogResetMessage = "check";
enum watchdogTriggerTime = 3.seconds;

version (Watchdog) void main(string[] args)
{   while (true)
     {   resetPipe = std.process.pipe();

         auto server = spawnProcess(["the web server"], stdin, 
resetPipe.writeEnd, stderr, null, Config.retainStdout | 

         auto watchdogTriggered = Clock.currTime;

         auto outputTask = spawn(function void(File file)
         {   foreach(line; file.byLine)
             {   if (line == watchdogResetMessage) 
                 else line.writeln;
         }, resetPipe.readEnd);

         //waits until no reset message is coing
         while (watchdogTriggerTime.receiveTimeout((ubyte){})) {}

         writeln(Clock.currTime.toISOExtString, ": Server does not 
sign life anymore. Restarting.");

The problem is that this won't pass compilation, because File 
contains theard-local indirection and thus cannot be sent to 
another theard.

I haven't done any complicated concurrency in D before. What's a 
good way to handle this?
May 14 2019