#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <stdarg.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
static char **arg_vip_proc_names = NULL;
static char **arg_vip_systemd_services = NULL;
+
+/* print log on console */
+static void vip_print_console(const char *format, ...)
+{
+ FILE *fp = NULL;
+ char buffer[256] = {0, };
+ int eno;
+ va_list ap;
+
+ fp = fopen("/dev/console", "a");
+ if (!fp) {
+ eno = errno;
+
+ va_start(ap, format);
+ vsnprintf(buffer, 256, format, ap);
+ va_end(ap);
+
+ errno = eno;
+ _E("%s(failed to print log on console, %m)", buffer);
+
+ return;
+ }
+
+ va_start(ap, format);
+ vfprintf(fp, format, ap);
+ va_end(ap);
+
+ fprintf(fp, "\n");
+
+ fclose(fp);
+}
+
/* copy of libsyscommon/libsystemd.c: systemd_get_unit_dbus_path() */
static int vip_get_escaped_name(const char *unit, char **escaped)
{
FOREACH_STRV(pname, arg_vip_proc_names) {
pid = find_pid_from_cmdline(*pname);
if (pid < 0) {
- _E("VIP %s not found", *pname);
+ vip_print_console("[VIP FAILED] %s is not running", *pname);
ret = false;
}
}
* been active before. Therefore, it is necessary to check
* whether it is still alive. */
if (pid == 0 || kill(pid, 0) != 0) {
- _E("VIP %s not found", *pname);
+ vip_print_console("[VIP FAILED] %s is not running", *pname);
ret = false;
}
}
static void vip_force_reboot(void)
{
- _E("VIP force reboot.");
+ vip_print_console("[VIP FAILED] Force reboot");
execl("/usr/bin/vip-release-agent", "/usr/bin/vip-release-agent", NULL);
_E("Failed to execute vip-release-agent");