NuProcess icon indicating copy to clipboard operation
NuProcess copied to clipboard

Alternative fix for linux race condition between onStart and onExit.

Open avrecko opened this issue 9 months ago • 2 comments

Continuing from #149.

Moved onStart processing to event processing thread. This way we make sure onStart is called first before any other EPoll event processing is done.

@bturner This is just my suggestion. Curious how you would fix it.

avrecko avatar May 01 '24 17:05 avrecko

@avrecko,

Thanks for the idea, but I'd prefer to keep it where the process manages onStart. The approach I'm leaning toward splits the existing IEventProcessor.registerProcess(T) method to extract a new queueRead (sibling to the existing queueWrite). With the split, registerProcess does the pidToProcessMap and fildesToProcessMap updates and queueRead does the epoll_ctl calls for stdout and stderr (on Linux; it does the kevent calls on macOS). This allows the LinuxProcess code to call registerProcess where it currently does, and then do a myProcessor.queueRead(this) after callStart.

I've opened pull request #158 with that approach, and I've tested it on all of the platforms I can.

bturner avatar May 05 '24 05:05 bturner

@bturner

Makes sense to do it this way. Keeping the threading model as is.

Looks good. I'd probably name the new method registerRead or something similar.

I trust the tests are now run with the build process and catch this case.

avrecko avatar May 05 '24 07:05 avrecko