summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/s6-linux-init-shutdownd.html9
-rw-r--r--doc/upgrade.html2
-rw-r--r--src/init/s6-linux-init-maker.c3
-rw-r--r--src/shutdown/s6-linux-init-shutdownd.c17
4 files changed, 27 insertions, 4 deletions
diff --git a/doc/s6-linux-init-shutdownd.html b/doc/s6-linux-init-shutdownd.html
index b0d42f4..7b504d9 100644
--- a/doc/s6-linux-init-shutdownd.html
+++ b/doc/s6-linux-init-shutdownd.html
@@ -27,7 +27,7 @@ directly by the user.
<h2> Interface </h2>
<pre>
- s6-linux-init-shutdownd [ -c <em>basedir</em> ] [ -g <em>gracetime</em> ] [ -C ] [ -B ]
+ s6-linux-init-shutdownd [ -d <em>notif</em> ] [ -c <em>basedir</em> ] [ -g <em>gracetime</em> ] [ -C ] [ -B ]
</pre>
<ul>
@@ -51,6 +51,13 @@ machine. </li>
<h2> Options </h2>
<ul>
+ <li> <tt>-d</tt>&nbsp;<em>notif</em>&nbsp;: when ready
+(actually listening to its named pipe),
+write a newline to file descriptor <em>notif</em> then close it.
+This allows s6-linux-init-shutdownd to use the
+<a href="//skarnet.org/software/s6/notifywhenup.html">s6 mechanism to notify
+readiness</a>. <em>notif</em> cannot be lesser than 3.
+If this option is not given, no readiness notification is sent. </li>
<li> <tt>-c&nbsp;<em>basedir</em></tt>&nbsp;: look for the
<em>rc.shutdown</em> script in the <em>basedir</em><tt>/scripts</tt>
directory. Default is <tt>/etc/s6-linux-init/current</tt>. </li>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index 8133a41..8c5e25a 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -23,6 +23,8 @@
<ul>
<li> <a href="//skarnet.org/software/skalibs/">skalibs</a>
dependency bumped to 2.13.2.0. </li>
+ <li> You should run <a href="s6-linux-init-maker.html">s6-linux-init-maker</a>
+again to take advantage of a minor bugfix. </li>
</ul>
<h2> in 1.1.1.1 </h2>
diff --git a/src/init/s6-linux-init-maker.c b/src/init/s6-linux-init-maker.c
index 98b9b46..d3b921d 100644
--- a/src/init/s6-linux-init-maker.c
+++ b/src/init/s6-linux-init-maker.c
@@ -186,7 +186,7 @@ static int shutdownd_script (buffer *b, char const *data)
size_t sabase = satmp.len ;
char fmt[UINT_FMT] ;
if (!put_shebang(b)
- || buffer_puts(b, S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-shutdownd -c ") < 0
+ || buffer_puts(b, S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-shutdownd -d3 -c ") < 0
|| !string_quote(&satmp, robase, strlen(robase))) return 0 ;
if (buffer_put(b, satmp.s + sabase, satmp.len - sabase) < 0) goto err ;
satmp.len = sabase ;
@@ -527,6 +527,7 @@ static inline void make_image (char const *base)
auto_dir(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" SHUTDOWND_SERVICEDIR, 0, 0, 0755) ;
auto_fifo(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" SHUTDOWND_SERVICEDIR "/" SHUTDOWND_FIFO) ;
+ auto_file(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" SHUTDOWND_SERVICEDIR "/notification-fd", "3\n", 2) ;
auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" SHUTDOWND_SERVICEDIR "/run", &shutdownd_script, 0) ;
if (inns)
diff --git a/src/shutdown/s6-linux-init-shutdownd.c b/src/shutdown/s6-linux-init-shutdownd.c
index be84baf..8b2741a 100644
--- a/src/shutdown/s6-linux-init-shutdownd.c
+++ b/src/shutdown/s6-linux-init-shutdownd.c
@@ -43,7 +43,7 @@
#define DOTSUFFIXLEN (sizeof(DOTSUFFIX) - 1)
#define CONTAINERDIR S6_LINUX_INIT_TMPFS "/" CONTAINER_RESULTS
-#define USAGE "s6-linux-init-shutdownd [ -c basedir ] [ -g gracetime ] [ -C ] [ -B ]"
+#define USAGE "s6-linux-init-shutdownd [ -d notif ] [ -c basedir ] [ -g gracetime ] [ -C ] [ -B ]"
#define dieusage() strerr_dieusage(100, USAGE)
static char const *basedir = BASEDIR ;
@@ -255,6 +255,7 @@ int main (int argc, char const *const *argv)
unsigned int grace_time = 3000 ;
tain deadline ;
int fdr, fdw ;
+ unsigned int notif = 0 ;
buffer b ;
char what = 'S' ;
char buf[64] ;
@@ -264,10 +265,11 @@ int main (int argc, char const *const *argv)
subgetopt l = SUBGETOPT_ZERO ;
for (;;)
{
- int opt = subgetopt_r(argc, argv, "c:g:CB", &l) ;
+ int opt = subgetopt_r(argc, argv, "d:c:g:CB", &l) ;
if (opt == -1) break ;
switch (opt)
{
+ case 'd' : if (!uint0_scan(l.arg, &notif)) dieusage() ; break ;
case 'c' : basedir = l.arg ; break ;
case 'g' : if (!uint0_scan(l.arg, &grace_time)) dieusage() ; break ;
case 'C' : inns = 1 ; break ;
@@ -279,6 +281,11 @@ int main (int argc, char const *const *argv)
}
if (basedir[0] != '/')
strerr_dief2x(100, "basedir", " must be an absolute path") ;
+ if (notif)
+ {
+ if (notif < 3) strerr_dief1x(100, "notification fd must be 3 or more") ;
+ if (fcntl(notif, F_GETFD) < 0) strerr_dief1sys(100, "invalid notification fd") ;
+ }
if (grace_time > 300000) grace_time = 300000 ;
/* if we're in stage 4, exec it immediately */
@@ -315,6 +322,12 @@ int main (int argc, char const *const *argv)
buffer_init(&b, &buffer_read, fdr, buf, 64) ;
tain_now_set_stopwatch_g() ;
tain_add_g(&deadline, &tain_infinite_relative) ;
+ if (notif)
+ {
+ write(notif, "\n", 1) ;
+ close(notif) ;
+ notif = 0 ;
+ }
for (;;)
{