> 2) Check the parent process id being 1
>    In this case parent of the parent because of mysqld_safe
>    # test $(ps -o ppid= -p $(ps -o ppid= -p $PID)) -eq 1
>    This would work in most cases I can think of. mysqld run by a user
>    or a container would not be started by the init. But seems like a
>    rather complex solution to a fairly simple problem.

Option 2 seems OK. Alternatively we could check processed owned by user 'mysql'.

Yes, the solution might be a bit complex, but I am fine with it as
long as the bash code is well documented and as clean as possible, so
that potential regressions/bugs in future are easy to track down and
new people are confident in tweaking the code. Try avoiding long
oneliners and short-cut code style (to the extend possible, it is
after all bash scripting).

Reply via email to