constexpr const char AUL_DBUS_SIGNAL_INTERFACE[] = "org.tizen.aul.signal";
constexpr const char AUL_DBUS_APPDEAD_SIGNAL[] = "app_dead";
constexpr const char AUL_DBUS_APPLAUNCH_SIGNAL[] = "app_launch";
+constexpr const char kLaunchpadProcessPoolSock[] =
+ ".launchpad-process-pool-sock";
class GarbageCollector : public Worker::Job {
public:
}
bool Launchpad::ListenSigchld() {
+ std::string path = GetEndpoint(uid_, kLaunchpadProcessPoolSock);
+ if (access(path.c_str(), F_OK) != 0) {
+ _W("%s doesn't exist", path.c_str());
+ return false;
+ }
+
try {
sigchld_socket_.reset(new ClientSocket());
std::string endpoint = GetEndpoint(uid_, LAUNCHPAD_PROCESS_POOL_SOCK);
channels_.erase(found);
}
-void Launchpad::HandleSigchldEvent() {
+bool Launchpad::HandleSigchldEvent() {
size_t data_size = 0;
int ret = sigchld_socket_->Receive(static_cast<void*>(&data_size),
sizeof(data_size));
if (ret != 0) {
_E("Receive() is failed. error=%d", ret);
- return;
+ return false;
}
std::vector<uint8_t> data(data_size);
ret = sigchld_socket_->Receive(data.data(), data_size);
if (ret != 0) {
_E("Receive() is failed. error=%d", ret);
- return;
+ return false;
}
tizen_base::Parcel parcel(data.data(), data.size());
}
if (listener_) listener_->OnSigchldEvent(pid, status);
+
+ return true;
}
gboolean Launchpad::UnixFdFunc(gint fd, GIOCondition cond, gpointer user_data) {
_D("fd=%d, cond=%d", fd, static_cast<int>(cond));
auto* self = static_cast<Launchpad*>(user_data);
- self->HandleSigchldEvent();
+ if (!self->HandleSigchldEvent()) {
+ self->IgnoreSigchld();
+ self->retry_source_ = g_timeout_add(100, RetryFunc, self);
+ }
return G_SOURCE_CONTINUE;
}
void SendAppLaunchSignal(pid_t pid, const std::string& appid);
void SendAppDeadSignal(pid_t pid, int status);
void OnResultReceived(int fd, int result) override;
- void HandleSigchldEvent();
+ bool HandleSigchldEvent();
bool ListenSigchld();
static gboolean UnixFdFunc(gint fd, GIOCondition cond, gpointer user_data);
static gboolean RetryFunc(gpointer user_data);