X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6a87962ff2bd64e3c863ea894dd745647e380c93..027295612d642dab025657808b3ab22304644aae:/teshsuite/msg/pid.c diff --git a/teshsuite/msg/pid.c b/teshsuite/msg/pid.c index ef21c7858b..0fee70ac43 100644 --- a/teshsuite/msg/pid.c +++ b/teshsuite/msg/pid.c @@ -1,11 +1,11 @@ -/* Copyright (c) 2009, 2010. The SimGrid Team. +/* Copyright (c) 2009-2010, 2013-2014. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "msg/msg.h" -#include "xbt/sysdep.h" +#include "xbt/sysdep.h" XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); @@ -13,15 +13,15 @@ const char* mailbox = "mailbox"; #define task_comp_size 1000 #define task_comm_size 100000 -static int onexit(void* data){ - XBT_INFO("Process \"%d\" killed.", *((int*)data)); +static int onexit(smx_process_exit_status_t status, int *pid){ + XBT_INFO("Process \"%d\" killed.", *pid); return 0; } static int sendpid(int argc, char *argv[]) { int pid = MSG_process_self_PID(); - MSG_process_on_exit(onexit, &pid); + MSG_process_on_exit((int_f_pvoid_pvoid_t)onexit, &pid); msg_task_t task = MSG_task_create("pid", task_comp_size, task_comm_size, &pid); XBT_INFO("Sending pid of \"%d\".", pid); MSG_task_send(task, mailbox); @@ -36,7 +36,8 @@ static int killall(int argc, char *argv[]){ int i; for (i=0; i<3;i++) { res = MSG_task_receive(&(task), mailbox); - int pid = *((int*)MSG_task_get_data(task)); + int pid = *(int*)MSG_task_get_data(task); + MSG_task_destroy(task); XBT_INFO("Killing process \"%d\".", pid); MSG_process_kill(MSG_process_from_PID(pid)); task = NULL; @@ -55,10 +56,10 @@ int main(int argc, char *argv[]) MSG_function_register("sendpid", &sendpid); MSG_function_register("killall", &killall); - MSG_process_killall(atoi(argv[2])); + MSG_process_killall(atoi(argv[3])); MSG_create_environment(argv[1]); - MSG_launch_application(argv[1]); + MSG_launch_application(argv[2]); res = MSG_main(); if (res == MSG_OK)