- int argc, char **argv, xbt_dict_t properties)
-{
- xbt_assert(code != NULL && host != NULL, "Invalid parameters: host and code params must not be NULL");
- simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1);
- msg_process_t process;
-
- /* Simulator data for MSG */
- simdata->waiting_action = NULL;
- simdata->waiting_task = NULL;
- simdata->m_host = host;
- simdata->argc = argc;
- simdata->argv = argv;
- simdata->data = data;
- simdata->last_errno = MSG_OK;
-
- /* Let's create the process: SIMIX may decide to start it right now,
- * even before returning the flow control to us */
- process = simcall_process_create(name, code, simdata, sg_host_get_name(host), -1, argc, argv, properties,0);
-
- if (!process) {
- /* Undo everything we have just changed */
- xbt_free(simdata);
- return NULL;
- }
- else {
- simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
- }
- return process;
+ int argc, char **argv, xbt_dict_t properties)
+{
+ std::function<void()> function;
+ if (code)
+ function = simgrid::xbt::wrapMain(code, argc, static_cast<const char* const*>(argv));
+
+ std::map<std::string, std::string> props;
+ xbt_dict_cursor_t cursor = nullptr;
+ char* key;
+ char* value;
+ xbt_dict_foreach (properties, cursor, key, value)
+ props[key] = value;
+ xbt_dict_free(&properties);
+
+ msg_process_t res = MSG_process_create_from_stdfunc(name, std::move(function), data, host, &props);
+ for (int i = 0; i != argc; ++i)
+ xbt_free(argv[i]);
+ xbt_free(argv);
+ return res;
+}