void InterpositionServer::run() { try { File(socketPath()).unlink(); } catch(...) {} socket_ = new StreamSocket(new SocketAddress(AF_LOCAL, socketPath())); socket_->bind(); socket_->listen(); while (!done_.tryAcquire()) { try { Ref<StreamSocket, Owner> stream = socket_->accept(); LineSource source(stream); LineSink sink(stream); String path = source.readLine(); String redirPath = redirectOpen(path); sink.writeLine(redirPath); /* NB: May be signalled in two different areas: * [A] in kernel (accept(2), read(2) or write(2)) * [B] during userlevel code execution (between the calls above) * In case [A] direct termination is guaranteed (throwing/catching StreamException). * In case [B] at most another connection will be accepted and handled completely. */ } catch (StreamException&) { break; } } }
bool QtServiceController::isRunning() const { QtUnixSocket sock; if (sock.connectTo(socketPath(serviceName()))) return true; return false; }
void InterpositionServer::injectClient(Ref<EnvMap> map) { map->insert("CODETIPS_SOCKET", socketPath()); String libPath = LinkInfo((void*)&codetips_hook).libraryPath().replace("codetips.", "codetipsclient."); #ifdef __MACH__ map->insert("DYLD_FORCE_FLAT_NAMESPACE", ""); map->insert("DYLD_INSERT_LIBRARIES", libPath); #else map->insert("LD_PRELOAD", libPath); #endif }
static bool sendCmd(const QString &serviceName, const QString &cmd) { bool retValue = false; QtUnixSocket sock; if (sock.connectTo(socketPath(serviceName))) { sock.write(QString(cmd+"\r\n").toLatin1().constData()); sock.flush(); sock.waitForReadyRead(-1); QString reply = sock.readAll(); if (reply == QLatin1String("true")) retValue = true; sock.close(); } return retValue; }
void QtServiceBasePrivate::sysSetPath() { if (sysd) sysd->setPath(socketPath(controller.serviceName())); }