Wait for submission result #4
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Research needed. Ideas:
How much should wbij be obtrusive when it get's the status? Should it try to get the control over terminal? Or only print one-line message?
Assuming wbij forks into the background and passes control of the shell back to the user, I would suggest it doesn't intrude at all -- I can see myself in the future being annoyed by having my outputs mangled. Instead I suggest a mode of operation as follows:
wbij submit (...)This way, we can return uninterrupted control of the shell back to the user if they so desire.
(nb. this is similar to how SiO2 operates during the POI final stage, where you can either keep working and wait for the judge notification, or switch focus to the browser and keep refreshing until the result pops up)
Fully agree. Good idea that there should be two hooks: just after submitting and after receiving submission results.
So... you want to
std.process.forkand thenexit(0)straight afterwards in the parent process, and then continue waiting for full submission results in the child process, right? From the child process, we can still write to the samestdout, as long as we have the same fd (and we do).But once the child process forks, how do you handle the case when the interactive terminal is closed? In standard case, closing terminal kills all subprocesses (through
SIGHUP), including our wbij child process. We can create a new session withsetsid()to detach completely from terminal session, so thatwbijchild is not killed. But, after terminal is closed, writing to stdout can result inEIO(I/O error) and we need to handle this explicitly.Do you create a new session with
setsid()to detach completely from terminal session, so thatwbijchild process is not killed, or do you do something else? How do you detect that terminal was closed?I'm curious to see your results! : )
Not really, while I do want to wait for the submission results in the background, I also want the foreground process to keep the interactive terminal occupied until the verdict is ready. The intention is that only the foreground will write to
stdout, so that if the user sends^Cthey can get back to work, and will (at least in the original intention) receive a desktop notification with a short summary, if they configure the second hook to do so.Yup, exactly!
Right now the way I do this is: the parent and child processes have a pipe open, so that the child process can transfer the verdict to the parent and later display it. We can detect if the parent is dead if it closes the reading end of the pipe, which will make
std.posix.writereturnerror.BrokenPipe; if this happens the child process will just run the post-result hook and exit.There is an issue though, as
std.posix.errnojust does not compile in zig 0.15.2, from which it follows thatstd.posix.setsidis unusable; this means that the full functionality is blocked by #13.I'm just about to start committing parts of the code I've written over the past few days; for now it's all still WIP but expect a PR from
kbity:feature/post-submitsometime soon ;3