mirror of
https://gitlab.com/niansa/libhss.git
synced 2025-03-06 20:49:21 +01:00
Updated to use QBiIPC instead of simple QIPC
This commit is contained in:
parent
574a8e191a
commit
21fb69b630
4 changed files with 15 additions and 11 deletions
|
@ -33,17 +33,17 @@ void enable_limits() {
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
// Get IPC
|
// Get IPC
|
||||||
if (argc != 4) {
|
if (argc != 6) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
QIPC ipc(std::stoi(argv[1]), std::stoi(argv[2]));
|
QBiIPC ipc({QIPC(std::stoi(argv[1]), std::stoi(argv[2])), QIPC(std::stoi(argv[3]), std::stoi(argv[4]))});
|
||||||
// Launch
|
// Launch
|
||||||
|
Dlhandle dl(argv[5], RTLD_NOW | RTLD_LOCAL);
|
||||||
|
auto entry = dl.get<void*(QBiIPC&)>("entry");
|
||||||
|
enable_limits();
|
||||||
close(STDIN_FILENO);
|
close(STDIN_FILENO);
|
||||||
close(STDOUT_FILENO);
|
close(STDOUT_FILENO);
|
||||||
close(STDERR_FILENO);
|
close(STDERR_FILENO);
|
||||||
Dlhandle dl(argv[3], RTLD_NOW | RTLD_LOCAL);
|
|
||||||
auto entry = dl.get<void*(QIPC&)>("entry");
|
|
||||||
enable_limits();
|
|
||||||
entry(ipc);
|
entry(ipc);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
void entry(QIPC& ipc) {
|
void entry(QBiIPC& ipc) {
|
||||||
ipc.send("Hello world!");
|
ipc.send("Hello world!");
|
||||||
ipc.send_raw(size_t(1234567890));
|
ipc.send_raw(size_t(1234567890));
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
QIPC ipc;
|
QBiIPC ipc;
|
||||||
ipc.create();
|
ipc.create();
|
||||||
|
|
||||||
HSS::run(ipc, "./libHSSTestChild.so");
|
HSS::run(ipc, "./libHSSTestChild.so");
|
||||||
|
|
12
hss.hpp
12
hss.hpp
|
@ -1,3 +1,4 @@
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <QIPC/ipc.hpp>
|
#include <QIPC/ipc.hpp>
|
||||||
|
@ -5,14 +6,17 @@
|
||||||
|
|
||||||
|
|
||||||
namespace HSS {
|
namespace HSS {
|
||||||
inline void run(QIPC& ipc, const std::string& file) {
|
inline void run(QBiIPC& ipc, const std::string& file) {
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
execlp("HSSChildLauncher", "child",
|
execlp("HSSChildLauncher", "child",
|
||||||
std::to_string(ipc.get_in()).c_str(),
|
std::to_string(ipc.out.get_in()).c_str(),
|
||||||
std::to_string(ipc.get_out()).c_str(),
|
std::to_string(ipc.out.get_out()).c_str(),
|
||||||
|
std::to_string(ipc.in.get_in()).c_str(),
|
||||||
|
std::to_string(ipc.in.get_out()).c_str(),
|
||||||
file.c_str(),
|
file.c_str(),
|
||||||
nullptr);
|
nullptr);
|
||||||
throw std::runtime_error("Failed to run HSSChildLauncher");
|
std::cerr << "Failed to run HSSChildLauncher" << std::endl;
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue