Linux blocked on file read on exit, need select

Darrell Gallion via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 20 15:52:27 PDT 2016


Program is blocked on exit, because of a blocking file read.
I'd be glad to just kill it and exit.

In this case I'm using dinotify, I exposed the fd.
This issue is it's not working or blocked on exit.

Never mind the constant monitor.add

static immutable string stdoutFn="passFiles/vAppStdout";

void monitorStdout(){
   auto monitor = iNotify();
   Watch watch = monitor.add(stdoutFn.ptr, IN_ALL_EVENTS );

   timeval timeout={tv_sec:0, tv_usec:500000 };

   //int flags = fcntl(monitor.fd, F_GETFL, 0);
   //fcntl(monitor.fd, F_SETFL, flags | O_NONBLOCK);

   while(run){
     fd_set fdset;
     FD_ZERO(&fdset);
     FD_SET(monitor.fd, &fdset);
     if(select(monitor.fd+1, &fdset, cast(fd_set*)null, 
cast(fd_set*)null, &timeout) ){
       auto events = monitor.read();
       watch = monitor.add(stdoutFn.ptr, IN_ALL_EVENTS );
   }

   writeln("Exit monitor");
}



More information about the Digitalmars-d-learn mailing list