Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
check that suiciding a process actually works in C
[simgrid.git] / examples / msg / process-kill / process-kill.c
index f83b68a..fe02ef8 100644 (file)
@@ -30,14 +30,15 @@ static int killer(int argc, char *argv[])
   XBT_INFO("Kill process");   /* - and then kill it */
   MSG_process_kill(poor_victim);
 
-  XBT_INFO("OK, goodbye now.");
+  XBT_INFO("OK, goodbye now. I commit a suicide.");
+  MSG_process_kill(MSG_process_self());
+
+  XBT_INFO("This line will never get displayed: I'm already dead since the previous line.");
   return 0;
 }
 
 int main(int argc, char *argv[])
 {
-  msg_error_t res = MSG_OK;
-
   MSG_init(&argc, argv);
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
 
@@ -45,7 +46,7 @@ int main(int argc, char *argv[])
   /* - Create and deploy killer process, that will create the victim process  */
   MSG_process_create("killer", killer, NULL, MSG_host_by_name("Tremblay"));
 
-  res = MSG_main();                 /* - Run the simulation */
+  msg_error_t res = MSG_main(); /* - Run the simulation */
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
   return res != MSG_OK;