| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Instead of straight removal, I'd try to find an adequate macro to put around that code: something like #ifndef __SYSTEMD__ (pseudo-code, I don't know if this actually exists) to avoid potentially breaking other init systems. |
Sorry, something went wrong.
|
Do others actually need this? And how did the old code manage this? |
Sorry, something went wrong.
|
I think this is the historical way of doing "daemons" processes. Maybe what's needed for systemd is the "-n" CLI argument. |
Sorry, something went wrong.
The old code ran daemon(), which isn't supported everywhere and is nonstandard, so for that reason I (basically) reimplemented it. Or, at least, tried to. I notice I don't actually ship a systemd unit file upstream, but for Debian I have this: [Unit] Description=Network Block Device server Documentation=man:nbd-server(1) After=network-online.target Wants=network-online.target [Service] Type=forking ExecStart=nbd-server ExecReload=kill -HUP $MAINPID PIDFile=nbd-server.pid NoNewPrivileges=true ProtectSystem=full [Install] WantedBy=multi-user.target ... and that seems to work for me (I think the crucial bit is the "PIDFile" part). I don't think this is working incorrectly (other than adding conditional code to notify systemd, but yuck), so I think closing this bug seems like the right thing to do? If I'm missing something, please do let me know. |
Sorry, something went wrong.
Well, yes. But looks like that did work without double fork as well.
This is the unit file we have for Arch Linux: ... and you are right, we do not have PIDFile in there. Either way... Having an upstream unit file would be great.
I will give this a try when I have some spare time, stay tuned. But anyway... Even if it works (mostly?) - I think the current code is racy. After fork() the parent does exit() immediately. So chances are that it is gone (and stops the service) before the child has written its pidfile. No idea how likely this is, though. |
Sorry, something went wrong.
|
Just testing with your (Debian) unit file. It does start successfully, but systemd logs: systemd[1]: nbd.service: Supervising process 87468 which is not our child. We'll most likely not notice when it exits. The given pid is from the grandchild. I guess you see this in Debian as well? |
Sorry, something went wrong.
... as this breaks as systemd service: This is of type 'forking', so the (first) fork becomes the main and controlling process. The second fork makes the main process exit, and the service is stopped. Calling setsid() should be sufficient to detatch from terminal. Closes: NetworkBlockDevice#182
| Back | FazBrowse Home | New Git URL |
... as this breaks as systemd service: This is of type 'forking', so the (first) fork becomes the main and controlling process. The second fork makes the main process exit, and the service is stopped.
Closes: #182