Discussion:
[gentoo-user] Program shutting down - where is its status held?
(too old to reply)
Peter Humphrey
2024-04-06 07:50:06 UTC
Permalink
Some of my machines run BOINC, which I want to stop while doing my sync &
update. For some reason, '/etc/init.d/boinc stop' often takes exactly 60s to
complete instead of its normal 6-10s.
I'd like my update script to detect this condition, but I can't see how.
I've tried grepping /bin/ps output, and I've tried checking for existence
of a BOINC pid file, but those both tell me that BOINC is "running" while
it's in the process of shutting down.
Is there somewhere in /proc where this shutting-down status is held?
Let me ask a different way: does start-stop-daemon keep the current, transient
status of the daemon it's operating on anywhere other than in its own
variables, and thus accessible for inspection?

I have tried reading the code, but I'm not familiar with the Linux way of
organising programs, and it's far too long since I did anything even remotely
similar.
--
Regards,
Peter.
Peter Humphrey
2024-04-06 07:52:13 UTC
Permalink
Personally, I would try to figure out why boinc doesn't want to stop
when you tell it to stop.
Actually, it does; all its daughter process do stop straight away. It's just
that it doesn't report completion when it should.
But barring that, you could add pre- and post-stop hooks that will let you
know that the daemon is stopping.
For example, in /etc/conf.d/boinc, you could put
stop_pre(){
touch /run/stopping-boinc
}
stop_post(){
rm -f /run/stopping-boinc
}
or something like that. (I haven't tested, but the idea is sound.)
Then, if that file exists, boinc is stopping.
Outstanding! I'll try that. Thank you Michael.

As to the primary problem, I think the BOINC team aren't entirely in tune with
the Linux way of doing things - though I could be wrong, of course. They're
university boffins, after all... :)
--
Regards,
Peter.
Peter Humphrey
2024-04-07 11:00:01 UTC
Permalink
But barring that, you could add pre- and post-stop hooks that will let you
know that the daemon is stopping.
For example, in /etc/conf.d/boinc, you could put
stop_pre(){
touch /run/stopping-boinc
}
stop_post(){
rm -f /run/stopping-boinc
}
or something like that. (I haven't tested, but the idea is sound.)
Then, if that file exists, boinc is stopping.
Nice, neat solution. Works a charm, too.

Thanks again, Michael.
--
Regards,
Peter.
Loading...