#!/usr/bin/execlineb -S1

if { mkdir -p /run/uncaught-logs ${1}/s6-svscan-log }
if { chown catchlog:catchlog /run/uncaught-logs }
if { chmod 2700 /run/uncaught-logs }
if { redirfd -w 1 ${1}/s6-svscan-log/notification-fd echo 3 }
foreground { redirfd -w 2 /dev/null mkfifo -m 0600 ${1}/s6-svscan-log/fifo }
unexport ?
if
{
  redirfd -w 1 ${1}/s6-svscan-log/run
  heredoc 0 "#!/usr/bin/execlineb -S1
fdmove -c 1 2
redirfd -rnb 0 fifo
s6-setuidgid catchlog
exec -c
s6-log -bpd3 -- t /run/uncaught-logs\n"
  cat
}
if { chmod 0755 ${1}/s6-svscan-log/run }

redirfd -r 0 /dev/null
redirfd -w 3 /dev/console
redirfd -wnb 1 ${1}/s6-svscan-log/fifo
fdmove -c 2 1
s6-svscan -X3 -- ${1}
