summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2021-03-30 14:19:24 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2021-04-01 10:57:30 +0900
commitfc56cf98b0757f132574535d6017b14f808bd807 (patch)
tree44ece2db6939bb904d01d45c422b725435468d59
parent3df1f613961c4a42d0bda6b20cb2e0255a4e8b40 (diff)
downloadlaunchpad-fc56cf98b0757f132574535d6017b14f808bd807.tar.gz
launchpad-fc56cf98b0757f132574535d6017b14f808bd807.tar.bz2
launchpad-fc56cf98b0757f132574535d6017b14f808bd807.zip
Redirect stdout to dlog
Before executing an application, the child process redirects stdout & stderr to dlog fd using connect_dlog() function. If stdout redirection is failed, the child process tries to redirect stdout to journal stream. Change-Id: I356a9fbb18504933e41ab1dddf67b65ddacc47db Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--CMakeLists.txt3
-rw-r--r--packaging/launchpad.spec1
-rw-r--r--src/app-defined-loader/CMakeLists.txt1
-rw-r--r--src/launchpad-loader/CMakeLists.txt1
-rw-r--r--src/launchpad-process-pool/CMakeLists.txt1
-rw-r--r--src/lib/common/src/launchpad_common.c20
-rw-r--r--src/lib/launchpad/CMakeLists.txt1
7 files changed, 26 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a8e0f5..063cd75 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,8 +54,9 @@ PKG_CHECK_MODULES(BUNDLE_DEPS REQUIRED bundle)
PKG_CHECK_MODULES(BUXTON2_DEPS REQUIRED buxton2)
PKG_CHECK_MODULES(DBUS_DEPS REQUIRED dbus-1)
PKG_CHECK_MODULES(DLOG_DEPS REQUIRED dlog)
-PKG_CHECK_MODULES(ECORE_DEPS REQUIRED ecore)
+PKG_CHECK_MODULES(DLOG_REDIRECT_STDOUT_DEPS REQUIRED dlog-redirect-stdout)
PKG_CHECK_MODULES(ECORE_CORE_DEPS REQUIRED ecore-core)
+PKG_CHECK_MODULES(ECORE_DEPS REQUIRED ecore)
PKG_CHECK_MODULES(ELEMENTARY_DEPS REQUIRED elementary)
PKG_CHECK_MODULES(GIO_DEPS REQUIRED gio-2.0)
PKG_CHECK_MODULES(INIPARSER_DEPS REQUIRED iniparser)
diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec
index b342780..e69df09 100644
--- a/packaging/launchpad.spec
+++ b/packaging/launchpad.spec
@@ -17,6 +17,7 @@ BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(ecore)
BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(dlog-redirect-stdout)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(vconf)
diff --git a/src/app-defined-loader/CMakeLists.txt b/src/app-defined-loader/CMakeLists.txt
index a7fa8bb..d588f4d 100644
--- a/src/app-defined-loader/CMakeLists.txt
+++ b/src/app-defined-loader/CMakeLists.txt
@@ -29,6 +29,7 @@ APPLY_PKG_CONFIG(${TARGET_APP_DEFINED_LOADER} PUBLIC
BUNDLE_DEPS
DBUS_DEPS
DLOG_DEPS
+ DLOG_REDIRECT_STDOUT_DEPS
ECORE_DEPS
ECORE_CORE_DEPS
GIO_DEPS
diff --git a/src/launchpad-loader/CMakeLists.txt b/src/launchpad-loader/CMakeLists.txt
index 091bba7..b768262 100644
--- a/src/launchpad-loader/CMakeLists.txt
+++ b/src/launchpad-loader/CMakeLists.txt
@@ -24,6 +24,7 @@ ENDIF(_TIZEN_FEATURE_PRELINK)
APPLY_PKG_CONFIG(${TARGET_LAUNCHPAD_LOADER} PUBLIC
DLOG_DEPS
+ DLOG_REDIRECT_STDOUT_DEPS
ECORE_DEPS
ELEMENTARY_DEPS
SECURITY_MANAGER_DEPS
diff --git a/src/launchpad-process-pool/CMakeLists.txt b/src/launchpad-process-pool/CMakeLists.txt
index 70732ff..b0af4fe 100644
--- a/src/launchpad-process-pool/CMakeLists.txt
+++ b/src/launchpad-process-pool/CMakeLists.txt
@@ -28,6 +28,7 @@ APPLY_PKG_CONFIG(${TARGET_LAUNCHPAD_PROCESS_POOL} PUBLIC
BUNDLE_DEPS
DBUS_DEPS
DLOG_DEPS
+ DLOG_REDIRECT_STDOUT_DEPS
GIO_DEPS
INIPARSER_DEPS
LIBCAP_DEPS
diff --git a/src/lib/common/src/launchpad_common.c b/src/lib/common/src/launchpad_common.c
index 7c4ab6f..47f5857 100644
--- a/src/lib/common/src/launchpad_common.c
+++ b/src/lib/common/src/launchpad_common.c
@@ -41,6 +41,7 @@
#include <sys/prctl.h>
#include <dbus/dbus.h>
#include <vconf.h>
+#include <dlog-redirect-stdout.h>
#include "launchpad_common.h"
#include "launchpad_types.h"
@@ -954,9 +955,18 @@ static int __redirect_stdin(void)
static int __redirect_stdout(const char *ident)
{
+ char buf[512];
int ret;
int fd;
+ setbuf(stdout, NULL);
+ snprintf(buf, sizeof(buf), "STDOUT_%s", ident);
+ ret = connect_dlog(LOG_ID_MAIN, STDOUT_FILENO, buf, DLOG_INFO);
+ if (ret != 0)
+ _W("connect_dlog() is failed. error(%d)", ret);
+ else
+ return 0;
+
fd = sd_journal_stream_fd(ident, LOG_INFO, 0);
if (fd < 0) {
if (fd != -ENOENT)
@@ -984,9 +994,18 @@ static int __redirect_stdout(const char *ident)
static int __redirect_stderr(const char *ident)
{
+ char buf[512];
int ret;
int fd;
+ setbuf(stderr, NULL);
+ snprintf(buf, sizeof(buf), "STDERR_%s", ident);
+ ret = connect_dlog(LOG_ID_MAIN, STDERR_FILENO, buf, DLOG_WARN);
+ if (ret != 0)
+ _W("connect_dlog() is failed. error(%d)", ret);
+ else
+ return 0;
+
fd = sd_journal_stream_fd(ident, LOG_WARNING, 0);
if (fd < 0) {
if (fd != -ENOENT)
@@ -1010,7 +1029,6 @@ static int __redirect_stderr(const char *ident)
close(fd);
return ret;
-
}
int _setup_stdio(const char *ident)
diff --git a/src/lib/launchpad/CMakeLists.txt b/src/lib/launchpad/CMakeLists.txt
index d43ea34..053920b 100644
--- a/src/lib/launchpad/CMakeLists.txt
+++ b/src/lib/launchpad/CMakeLists.txt
@@ -18,6 +18,7 @@ APPLY_PKG_CONFIG(${TARGET_LAUNCHPAD} PUBLIC
BUXTON2_DEPS
DBUS_DEPS
DLOG_DEPS
+ DLOG_REDIRECT_STDOUT_DEPS
LIBCAP_DEPS
LIBSYSTEMD_DEPS
LIBTZPLATFORM_CONFIG_DEPS