My understanding is that it's generally a good idea to create a PID file for daemon processes and that
startproc is a good way to start these daemons.
I know that
startproc takes -i and -p arguments that refer to PID files but it doesn't create a PID file or update it with the ID of the daemon process that it starts. Echoing
$! also doesn't give the right process identifier when
startproc is used.
Does anyone have any advice as to how the PID of a daemon started with
startproc can be elicited?
For what it's worth, I'm writing an rc script and want to start a JVM as a non-privileged user. I don't really want to give this user a login shell (so
su -c "java ..." user is not an option) and I don't really want a root process hanging around while the daemon is running either (which rules out
sudo -Eu user java ...). So, while I acknowledge that these are possible workarounds, I don't find either of them to be ideal. Please feel free, though, to correct me if my assumptions about these alternatives are wrong.