BUG: https://bugzilla.samba.org/show_bug.cgi?id=12113
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
If a 0 status code is sent then it the helper should periodically
check if the (original) parent processes still exists while awaiting
termination. If the parent process disappears then the helper should
-release the mutex and exit. This avoids stale mutexes.
+release the mutex and exit. This avoids stale mutexes. Note that a
+helper should never wait for parent process ID 1!
If a non-0 status code is sent then the helper can exit immediately.
However, if the helper does not exit then it must terminate if it
}
ppid = getppid();
+
+ if (ppid == 1) {
+ /* The original parent is gone and the process has
+ * been reparented to init. This can happen if the
+ * helper is started just as the parent is killed
+ * during shutdown. The error message doesn't need to
+ * be stellar, since there won't be anything around to
+ * capture and log it...
+ */
+ fprintf(stderr, "%s: PPID == 1\n", progname);
+ exit(1);
+ }
+
file = argv[1];
result = fcntl_lock(file, &fd);