int fakeLogOpen(const char *pathName, int flags) { if (redirectOpen == NULL) { setRedirects(); } return redirectOpen(pathName, flags); }
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; } } }