-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
PROJECT("profctl")
MESSAGE("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
SET(CMAKE_C_FLAGS_DEBUG "-O2 -g")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
+OPTION(TIZEN "Tizen platform" ON)
+ADD_DEFINITIONS(-DTIZEN=$<BOOL:${TIZEN}>)
+
SET(PROFCTL "profctl")
SET(${PROFCTL}_SOURCE_FILES
profctl.c
)
ADD_EXECUTABLE(${PROFCTL} ${${PROFCTL}_SOURCE_FILES})
SET_TARGET_PROPERTIES(${PROFCTL} PROPERTIES COMPILE_FLAGS "-fPIE")
-TARGET_LINK_LIBRARIES(${PROFCTL} aul)
+IF(${TIZEN})
+ TARGET_LINK_LIBRARIES(${PROFCTL} aul)
+ENDIF(${TIZEN})
TARGET_LINK_LIBRARIES(${PROFCTL} ${${PROJECT_NAME}_LDFLAGS} "-pie -lpthread")
SET_TARGET_PROPERTIES(${PROFCTL}
#define _GNU_SOURCE
+#ifndef TIZEN
+#define TIZEN 1
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <signal.h>
#include <pthread.h>
+
+#if TIZEN
#include <termios.h>
#include <aul/aul.h>
+#endif /* TIZEN */
#include <sys/time.h>
#include <sys/types.h>
static int doinfo = 0;
static int timeoutMicrosec = 500000; // 0.5 seconds
static int pid = -1;
+#if TIZEN
static struct termios sterm;
+#endif /* TIZEN */
static char *appid = NULL;
static char *pname = NULL;
exit(0);
}
+#if TIZEN
static void *wait_thread(void *arg)
{
while (aul_app_get_status_bypid(pid) >= 0)
sleep(1);
exit(0);
}
+#endif /* TIZEN */
static void finish()
{
+#if TIZEN
tcsetattr(0,TCSANOW, &sterm);
+#endif /* TIZEN */
if (tf != NULL) {
fclose(tf);
if (isPipeOwner) {
value[0] = optarg;
}
+#if TIZEN
static int output_app_info(const aul_app_info *info, void *data)
{
if (info == NULL || info->appid == NULL)
info->pid, info->status, info->appid);
return 0;
}
+#endif /* TIZEN */
static int ListApps(int n)
{
+#if TIZEN
aul_app_get_all_running_app_info(output_app_info, NULL);
+#endif /* TIZEN */
exit(0);
}
}
+#if TIZEN
static int find_pid(const aul_app_info *info, void *data)
{
if (!strcmp(appid, info->appid)) {
exit(1);
}
-#if 1
static int app_launch_handler(int npid, const char *app_id, void *data)
{
if (verbose) {
exit(0);
return 1;
}
-#endif
+#endif /* TIZEN */
static void openFileProcess()
{
int main(int argc, char **argv)
{
+#if TIZEN
struct termios term;
+#endif /* TIZEN */
char *line = NULL;
size_t len = 0;
while(!process_option(argc, argv));
+#if TIZEN
if (appid == NULL) {
fprintf(stderr, "Unknown app id\n");
exit(1);
}
+#endif /* TIZEN */
if (oname == NULL) {
oname = "/tmp/profctl.log";
perror("mkfifo");
exit(1);
}
+#if TIZEN
/* This may be useful for "root on" start */
if (setxattr(pname, "security.SMACK64", "User::App::Shared",
strlen("User::App::Shared"),0)) {
perror("setattr");
}
+#endif /* TIZEN */
}
+#if TIZEN
/* stty */
tcgetattr(0, &term);
sterm = term;
term.c_oflag &= ~OPOST; /* no additional CR and so on */
tcsetattr(0,TCSANOW, &term);
+#endif /* TIZEN */
atexit(finish);
SimpleThread(&output_thread);
}
-#if 1
+#if TIZEN
aul_listen_app_launch_signal_v2(app_launch_handler, NULL);
aul_listen_app_dead_signal(app_dead_handler, NULL);
-#endif
+#endif /* TIZEN */
/* Read command loop */
while((len = getline(&line, &len, stdin)) != -1) {
if (kill(pid, SIGRTMIN+7))
perror("kill");
} else if (!strncmp(line, "test", 4) && (pid == -1)) {
+#if TIZEN
waitappid(10); /* try 10 seconds */
+#else
+ pid = getpid();
+#endif /* TIZEN */
if (verbose) {
fprintf(stderr, "pid = %d\n", pid);
}