Skip to content

Commit

Permalink
Merge pull request #22 from glerchundi/master
Browse files Browse the repository at this point in the history
avoid no-catchall stage1<->stage2 race condition, thanks Laurent
  • Loading branch information
glerchundi committed Mar 18, 2015
2 parents 82d054e + 54c3cbc commit 8b8dc0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions builder/build-latest
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ for output in "${outputs[@]}"; do
mkdir -p $overlaydstpath/etc/{cont-init.d,fix-attrs.d,services.d}
mkdir -p $overlaydstpath/var/log/s6-uncaught-logs

# create event directory in fdholder, its needed for no-catchall
# create "supervise" directory in fdholder, its needed for no-catchall
# stage2 wake up
mkdir -p $overlaydstpath/etc/s6/services/s6-fdholderd/event
chmod 3730 $overlaydstpath/etc/s6/services/s6-fdholderd/event
mkdir -p $overlaydstpath/etc/s6/services/s6-fdholderd/supervise
chmod 0700 $overlaydstpath/etc/s6/services/s6-fdholderd/supervise

# fix fix-attrs perms
chmod 0755 $overlaydstpath/usr/bin/fix-attrs
Expand Down
19 changes: 10 additions & 9 deletions builder/overlay-rootfs/etc/s6/init-no-catchall/init-stage1
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ if { s6-hiercopy /etc/s6/services /var/run/s6/services }
if { s6-rmrf /var/run/s6/services/s6-svscan-log }


##
## ensure our vital fifo exists
##

if { s6-mkfifo -m 0600 /var/run/s6/services/s6-fdholderd/supervise/control }


##
## fork the "init-stage2" script
##

background
{
# block until the supervision tree is running
# NOTE: start waiting as soon as possible because we can get
# into a race condition if "s" was already sent before we
# started listening to the fifodir.
if
{
# keep stderr open, but avoid "s" printing to the outside
redirfd -w 1 /dev/null
s6-ftrig-wait /var/run/s6/services/s6-fdholderd/event "s"
}
redirfd -w 3 /var/run/s6/services/s6-fdholderd/supervise/control
fdclose 3

# add some environment
s6-envdir -- /etc/s6/init/env-stage2
Expand All @@ -34,6 +34,7 @@ background
}
unexport !


##
## run the rest of stage 1 with sanitized descriptors
##
Expand Down

0 comments on commit 8b8dc0f

Please sign in to comment.