Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
/ listen-like-systemd Public archive

Command to emulate systemd socket activation fd passing

License

Notifications You must be signed in to change notification settings

tv42/listen-like-systemd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

listen-like-systemd -- Open a listening socket and pass it to subprocess

This program performs the parent side of systemd's socket activation dance. This is useful for e.g. development, where you want to run a program like it was socket activated, but not create a systemd service for it.

listen-like-systemd has pretty much been obsoleted by systemd's own systemd-socket-activate command, though I still prefer the calling convention used here.

Bugs

can overwrite actively used fds 3, 4, ...

  • systemd design forces passed fds to be numbered starting from 3
  • Go runtime on BSD derivatives uses an fd around 3-5 to hold open kqueue fd
  • there's a race in where runtime could try to use the supposedly-kqueue fd after our dup2
  • could push dup2 later, to minimize window; seems impossible to actually fix, with pure Go
  • could fork and leave parent running, and avoid the issue by using https://pkg.go.dev/os#ProcAttr.Files to adjust the FD numbers, but leaving the parent around is ugly and would mess up LISTEN_PID

About

Command to emulate systemd socket activation fd passing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages