#include <device-node.h>
#include <bundle.h>
#include <eventsystem.h>
+#include <stdbool.h>
#include <libgdbus/dbus-system.h>
#include "dd-deviced.h"
return 0;
}
+/* processes might start to fail abnormally after we kill them via
+ * umount_partition_by_kill. Failing services can trigger coredump
+ * handler, which might have trouble handling core in inconsistent
+ * system state (eg. lack of /opt). Due to this we disable the
+ * coredump handler for the shutdown period.
+ */
+static bool disable_coredump_handler(void)
+{
+ int ret = 0;
+ int fd = open("/proc/sys/kernel/core_pattern", O_WRONLY);
+ if (fd >= 0) {
+ ret = write(fd, "/dev/null", sizeof("/dev/null") - 1);
+ close(fd);
+ }
+
+ bool is_ok = fd > 0 && ret > 0;
+ _I("Disabling core dumps %s", is_ok ? "succeeded" : "failed");
+
+ return is_ok;
+}
+
/* umount usr data partition */
static void unmount_rw_partition(void)
{
disable_display();
disable_systemd_journald();
+ disable_coredump_handler();
buf = getenv("PWROFF_DUR");
if (buf != NULL && strlen(buf) < 1024)