#include "launchpad_proc.h"
#include "launchpad_signal.h"
#include "launchpad_socket.h"
+#include "launchpad_worker.h"
#include "log_private.h"
#define HYDRA_SIGCHLD_SOCK ".hydra-sigchld-sock"
+#define GPOINTER_TO_INT_SAFE(x) ((unsigned long)(x) & UINT32_MAX)
static pid_t __pid;
static sigset_t __mask;
static io_channel_h __hydra_sigchld_channel;
static signal_sigchld_cb __callback;
static void *__user_data;
+static worker_h __recycle_bin;
static gboolean __hydra_sigchld_recovery_cb(gpointer data);
static gboolean __sigchld_recovery_cb(gpointer data);
closedir(dp);
}
-static void __sigchld_action(int pid)
+static void __delete_unused_files(pid_t pid)
{
- _dbus_send_app_dead_signal(pid);
+ DIR *dp;
+ struct dirent *dentry;
+ char file_clr_debug_pipe[128];
+ size_t length_clr_debug_pipe;
+ char file_dotnet_diagnostic[128];
+ size_t length_dotnet_diagnostic;
+ char path[PATH_MAX];
+
+ dp = opendir("/tmp");
+ if (dp == NULL) {
+ _E("opendir() is failed");
+ return;
+ }
+
+ snprintf(file_clr_debug_pipe, sizeof(file_clr_debug_pipe),
+ "clr-debug-pipe-%d-", pid);
+ length_clr_debug_pipe = strlen(file_clr_debug_pipe);
+ snprintf(file_dotnet_diagnostic, sizeof(file_dotnet_diagnostic),
+ "dotnet-diagnostic-%d-", pid);
+ length_dotnet_diagnostic = strlen(file_dotnet_diagnostic);
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (dentry->d_name[0] == '.')
+ continue;
+
+ if (dentry->d_name[0] == 'c') {
+ if (length_clr_debug_pipe > strlen(dentry->d_name))
+ continue;
+
+ if (!strncmp(file_clr_debug_pipe, dentry->d_name,
+ length_clr_debug_pipe)) {
+ snprintf(path, sizeof(path), "/tmp/%s",
+ dentry->d_name);
+ unlink(path);
+ _W("unlink(%s)", path);
+ }
+ } else if (dentry->d_name[0] == 'd') {
+ if (length_dotnet_diagnostic > strlen(dentry->d_name))
+ continue;
+
+ if (!strncmp(file_dotnet_diagnostic, dentry->d_name,
+ length_dotnet_diagnostic)) {
+ snprintf(path, sizeof(path), "/tmp/%s",
+ dentry->d_name);
+ unlink(path);
+ _W("unlink(%s)", path);
+ }
+ }
+ }
+ closedir(dp);
+}
+
+static bool __garbage_collector(void* user_data)
+{
+ pid_t pid = GPOINTER_TO_INT_SAFE(user_data);
+
+ _W("pid(%d)", pid);
_delete_sock_path(pid, getuid());
+ __delete_unused_files(pid);
__socket_garbage_collector();
+ return false;
+}
+
+static void __sigchld_action(int pid)
+{
+ _dbus_send_app_dead_signal(pid);
+ _worker_add_job(__recycle_bin, __garbage_collector,
+ GINT_TO_POINTER(pid));
}
static int __check_permission(int pid)
}
}
+ ret = _worker_create("RecycleBin+", &__recycle_bin);
+ if (ret < 0) {
+ _E("_worker_create() is failed");
+ return ret;
+ }
+
return 0;
}
#endif
_D("SIGNAL_FINI");
+ if (getpid() == __pid)
+ _worker_destroy(__recycle_bin);
+
_signal_set_sigchld_cb(NULL, NULL);
__hydra_sigchld_fini();
__sigchld_fini();