[GNC] Locked out of gnucash
Derek Atkins
derek at ihtfp.com
Mon Nov 25 15:41:58 EST 2019
HI,
On Mon, November 25, 2019 2:01 pm, David Carlson wrote:
> If I understand, Derek, you are proposing a change to GnuCash code to
> improve it's behavior.
Yes, I am proposing a small code change. I'll note that even changing the
text of the message involves a code change, albeit a much smaller one.
> Going back to the original question, which was about the confusing wording
> of the warning, if the code is changed, should there be warnings tailored
> to each of the three cases?
I would think so, yes.
> Note: Case 1 might mean that some third party app such as a file editor
> may
> be mucking around. Is this true? Is it possible to test the PID to see
> if
> it is dead or alive?
I believe that there is a way to test if a process is alive by sending it
a kill(3) command and testing the return value. Specifically (from the
kill(3) man page):
The kill() function shall send a signal to a process or a group of
pro‐
cesses specified by pid. The signal to be sent is specified by sig
and
is either one from the list given in <signal.h> or 0. If sig is 0
(the
null signal), error checking is performed but no signal is
actually
sent. The null signal can be used to check the validity of pid.
So we can just run the following code to test cases #1 and #2:
if (kill(old_pid, 0) == 0) {
// process is still running -- possibly duplicate gnucash?
} else {
// no process running -- crash/bad-shutdown?
}
-derek
--
Derek Atkins 617-623-3745
derek at ihtfp.com www.ihtfp.com
Computer and Internet Security Consultant
More information about the gnucash-user
mailing list