- /* Unregister from the kill timer if any */
- if (process->kill_timer != nullptr)
- SIMIX_timer_remove(process->kill_timer);
-
- xbt_os_mutex_acquire(simix_global->mutex);
-
- /* cancel non-blocking communications */
- smx_activity_t synchro = static_cast<smx_activity_t>(xbt_fifo_pop(process->comms));
- while (synchro != nullptr) {
- simgrid::kernel::activity::Comm *comm = static_cast<simgrid::kernel::activity::Comm*>(synchro);
-
- /* make sure no one will finish the comm after this process is destroyed,
- * because src_proc or dst_proc would be an invalid pointer */
- comm->cancel();
-
- if (comm->src_proc == process) {
- XBT_DEBUG("Found an unfinished send comm %p (detached = %d), state %d, src = %p, dst = %p",
- comm, comm->detached, (int)comm->state, comm->src_proc, comm->dst_proc);
- comm->src_proc = nullptr;
-
- /* I'm not supposed to destroy a detached comm from the sender side, */
- if (comm->detached)
- XBT_DEBUG("Don't destroy it since it's a detached comm and I'm the sender");
- else
- comm->unref();
-
- }
- else if (comm->dst_proc == process){
- XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p",
- comm, (int)comm->state, comm->src_proc, comm->dst_proc);
- comm->dst_proc = nullptr;
-
- if (comm->detached && comm->src_proc != nullptr) {
- /* the comm will be freed right now, remove it from the sender */
- xbt_fifo_remove(comm->src_proc->comms, comm);
- }
-
- comm->unref();
- } else {
- xbt_die("Communication synchro %p is in my list but I'm not the sender nor the receiver", synchro);
- }
- synchro = static_cast<smx_activity_t>(xbt_fifo_pop(process->comms));
+ simix_global->process_list.erase(process->pid_);
+ if (process->host_ && process->host_process_list_hook.is_linked())
+ simgrid::xbt::intrusive_erase(process->host_->pimpl_->process_list_, *process);
+ if (not process->smx_destroy_list_hook.is_linked()) {
+#if SIMGRID_HAVE_MC
+ xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, process);
+#endif
+ simix_global->process_to_destroy.push_back(*process);