From: Ian Jackson Date: Sun, 21 Aug 2022 11:34:39 +0000 (+0100) Subject: prefork-interp: pass startup mtime X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=c659f9b31f36e65ae84de7c4376da9e019a1f4e7;p=chiark-utils.git prefork-interp: pass startup mtime Signed-off-by: Ian Jackson --- diff --git a/cprogs/prefork-interp.c b/cprogs/prefork-interp.c index fb1be68..0b4988d 100644 --- a/cprogs/prefork-interp.c +++ b/cprogs/prefork-interp.c @@ -724,11 +724,14 @@ void become_setup(int sfd, int lockfd, int fake_pair[2], // Extension could work like this: // - // We advertise a new protocol (perhaps one which is nearly entirely + // We could advertise a new protocol (perhaps one which is nearly entirely // different after the connect) by putting a name for it comma-separated // next to "v1". Simple extension can be done by having the script // side say something about it in the ack xdata, which we currently ignore. - putenv(m_asprintf("PREFORK_INTERP=v1 %d,%d,%d,%d", + // Or we could add other extra data after v1. + putenv(m_asprintf("PREFORK_INTERP=v1,%jd.%09ld %d,%d,%d,%d", + (intmax_t)initial_stab.st_mtim.tv_sec, + (long)initial_stab.st_mtim.tv_nsec, sfd, call_fd, watcher_stdin, watcher_stderr)); execvp(executor_argv[0], (char**)executor_argv); diff --git a/pm/Proc/Prefork/Interp.pm b/pm/Proc/Prefork/Interp.pm index d1d99ee..d11051f 100644 --- a/pm/Proc/Prefork/Interp.pm +++ b/pm/Proc/Prefork/Interp.pm @@ -19,6 +19,7 @@ our $env_name = 'PREFORK_INTERP'; our @call_fds; our $socket_path; our $fail_log = 0; +our $startup_mtime; sub fail_log ($) { my ($m) = @_; @@ -162,7 +163,8 @@ sub initialisation_complete { my @env_data = split / /, ($ENV{$env_name} // return); croak "$env_name has too few words" unless @env_data >= 2; my (@vsns) = split /,/, $env_data[0]; - croak "$env_name doesn't offer protocol v1" unless grep { $_ eq 'v1' } @vsns; + croak "$env_name doesn't specify v1" unless @vsns >= 2 && $vsns[0] eq 'v1'; + $startup_mtime = $vsns[1]; my @env_fds = split /,/, $env_data[1]; croak "$env_name has too few fds" unless @env_fds >= 4;; $#env_fds = 3;