From: Ian Jackson Date: Sat, 20 Aug 2022 14:26:12 +0000 (+0100) Subject: prefork-interp: diagrams X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=cff4d963543e7e04df71f07b102a338f65fe4962;p=chiark-utils.git prefork-interp: diagrams Signed-off-by: Ian Jackson --- diff --git a/cprogs/prefork-interp.c b/cprogs/prefork-interp.c index f0bc785..105f21c 100644 --- a/cprogs/prefork-interp.c +++ b/cprogs/prefork-interp.c @@ -62,88 +62,99 @@ |fork/exec | CLIENT(C) - tidy up stale sockets etc. - acquire lock - create listening socket | - fork/daemonise + attempt to connect, and read greeting + |failure? \success? + | \ + tidy up stale /run entries continue from send_fds, below + acquire lock + | + retry attempt to connect, and read greeting + |failure? \success? + | \ + create listening socket release lock + | \ + fork/daemonise continue from send_fds, below | `------------------. | WATCHER(C) && | - make "fake" initial call socketpair - | - fork/exec - | `------. - | SCRIPT (setup) - | | - | script initialisation - | | - | identify fds from envirnment - | open syslog - | | - | dzemonize - | ,...../ | - waitpid | - | fork for initial service - | |child |parent - | | | - | | SCRIPT [server] && - | | | - | | ** accept / event loop ** - | | / \ \ \ - | | accepted? \ \ \idle timeout? - | | | \ \ \ - | | fork child \ \ \ - | | _________/ watch | |watch stderr eof? - | |/ stderr| | | - | SCRIPT [monitor] | | | - | | log msg | | - | send greeting | | | - read greeting | | | | - | | exit - release lock | - | | + make "fake" initial call socketpair + | C prefork-interp + fork/exec + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | `------. Perl, application + | + SCRIPT (setup) + | + | + | + script initialisation + | + | Perl, application + | + + + +| + + + + + + + + + + + + + + + + + + + + + + + + + | + | Perl, prefork-interp + | + identify fds from envirnment + | + open syslog + | + | + | + dzemonize + | ,...../ | + waitpid + | + | + fork for initial service + | + |child |parent + | + | | + | + | SCRIPT [server] && + | + | | + | + | ** accept / event loop ** + | + | / \ \ \ + | + | accepted? \ \ \idle timeout? + | + | | \ \ \ + | + | fork child \ \ \ + | + | _________/ watch | |watch stderr eof? + | + |/ stderr| | | + | + SCRIPT [monitor] | | | + | + | log msg | | + | + setpgrpt & | | | + | + | | | | + | + send greeting | | | + read greeting | exit + | + | + release lock | from read greeting success, above + | ________ | ________/ + | / + | send fds.... | - | receive fds - | | - | fork for executor - | | \ - | | \child - | | \ - | | setpgrp & - | | execute service - | | | - | wait for read | - | (select) | - | | | | - | | exits - | | kernel closes execterm - | | ,......./| - | execterm? | - | | zombie - | | ,....../ - | waitpid - | | - | send exit status - read exit status - + | + receive fds + | + | + | + fork for executor + | + p |parent \child Perl, prefork-interp + | + | + + + + \+ + + + + + + + + + + + + + + + + | + | + execute service Perl, application + | + | + | + | +wait for read + | + | + (select) + | + | + | | + | + | + | + exits + | + | + kernel closes execterm + | + | ,.........../| + | + execterm? + | + | + | + zombie + | + | ,........../ + | + waitpid + + | + | + + | ,..,..send status + + read status + + + + + Or, if client is killed - | | | - | wait for read | - | (select) | - | | | | - exits | | - | | | - kernel closes | | - \....| | - call? | - | | - kill whole pgrp... | - | killled - | zombie - | ,....../ + | | | + | wait for read | + | (select) | + | | | | + exits | | + | | | + kernel closes | | + \....| | + call? | + | | + kill whole pgrp... | + | killled + | zombie + | ,..... ./ waitpid | send exit status