This is an archive of the discontinued LLVM Phabricator instance.

Support: Add polling option to sys::Wait
ClosedPublic

Authored by arsenm on Nov 29 2022, 2:30 PM.

Details

Summary

Currently the process is terminated after the timeout. Add an option
to let the process resume after the timeout instead.

WIP because of windows support. No idea if the Windows part even
builds, much less works.

Diff Detail

Event Timeline

arsenm created this revision.Nov 29 2022, 2:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 2:30 PM
arsenm requested review of this revision.Nov 29 2022, 2:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 2:30 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm updated this revision to Diff 479438.Dec 1 2022, 2:42 PM

Rebase on top of std::optional change

aganea added inline comments.Dec 1 2022, 3:56 PM
llvm/lib/Support/Unix/Program.inc
465

Out of curiosity (sorry I am not well versed into Linux APIs) -- who does stop the child process & when?

arsenm added inline comments.Dec 1 2022, 4:04 PM
llvm/lib/Support/Unix/Program.inc
465

Above a signal handler was installed. The process receives SIGALRM after the timeout from the OS. The original path here then killed off the child; this instead sends the signal to continue

aganea added inline comments.Dec 2 2022, 6:34 AM
llvm/lib/Support/Unix/Program.inc
465

The alarm signal/handler is received in the context of the parent process. The child process' state is unaffected by the alarm, right? I suppose the alarm has the effect to make wait4() return (from what I understand from the doc), but again, this doesn't affect the state of the child, does it? The child should be in a 'running' state at this point. So my question is, why do we need to send SIGCONT at all to the child?

arsenm updated this revision to Diff 479654.Dec 2 2022, 8:56 AM

Don't send SIGCONT, rename test

llvm/lib/Support/Unix/Program.inc
465

I don't know what I was doing before, but I added this to fix it waiting forever. Maybe I just had another bug in an earlier revision, my tests work with this removed

aganea added inline comments.Dec 2 2022, 1:39 PM
llvm/lib/Support/Unix/Program.inc
431

I wouldn't return right away, ProcStat is not yet updated at this point. I think enclosing all this into if (!Polling) like before would be fine. Seems good otherwise.

arsenm updated this revision to Diff 484714.Dec 21 2022, 4:22 PM
arsenm retitled this revision from Support: Add polling option to sys::Wait [WIP] to Support: Add polling option to sys::Wait.

Address comment. Build bot also implies it at least builds on windows with a passed unit test

aganea accepted this revision.Dec 22 2022, 5:29 AM

LGTM.

This revision is now accepted and ready to land.Dec 22 2022, 5:29 AM