- simix_global->default_function = [executable_copy](std::vector<std::string> args) {
- return std::function<void()>([executable_copy, args] {
+
+ // Prepare the copy of the binary (open the file and get its size)
+ // (fdin will remain open for the whole process execution. That's a sort of leak but we can live with it)
+ int fdin = open(executable_copy.c_str(), O_RDONLY);
+ xbt_assert(fdin >= 0, "Cannot read from %s", executable_copy.c_str());
+ struct stat fdin_stat;
+ fstat(fdin, &fdin_stat);
+ off_t fdin_size = fdin_stat.st_size;
+
+ simix_global->default_function = [executable_copy, fdin, fdin_size](std::vector<std::string> args) {
+ return std::function<void()>([executable_copy, fdin, fdin_size, args] {