static int isPipeOwner = 0;
+static FILE *orig_stdin = NULL;
+static FILE *orig_stdout = NULL;
static FILE *orig_stderr = NULL;
static int controlPort = -1;
}
#endif /* TIZEN */
+// On Tizen, launch_app won't terminate until stdin, stdout and stderr are closed
+static void finish_close_stdio()
+{
+ if (orig_stdin != NULL) {
+ fclose(orig_stdin);
+ }
+ if (orig_stdout != NULL) {
+ fclose(orig_stdout);
+ }
+ if (orig_stderr != NULL) {
+ fclose(orig_stderr);
+ }
+}
+
static void finish()
{
#if TIZEN
}
if (data_file_out != NULL) {
fflush(data_file_out);
+ if (data_file_out != orig_stdout) {
+ fclose(data_file_out);
+ }
}
log_error("=== finished ===");
+ finish_close_stdio();
kill(getpid(), SIGKILL);
}
int main(int argc, char **argv)
{
+ orig_stdin = stdin;
+ orig_stdout = stdout;
+ orig_stderr = stderr;
+
+ atexit(finish_close_stdio);
+
if (pthread_mutex_init(&stderr_lock, NULL) != 0)
{
perror("mutex init failed\n");
while(!process_option(argc, argv));
+ atexit(finish);
+
#if TIZEN
if (appid == NULL) {
log_error("Unknown app id");
log_system_error_and_exit("freopen");
}
setlinebuf(redir_stderr);
- orig_stderr = stderr;
stderr = redir_stderr;
if (verbose) {
}
}
- atexit(finish);
-
if (pname) {
SimpleThread(&output_thread);
}