Author Topic: sending variables to a signal function  (Read 33 times)

Shawnturner

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
sending variables to a signal function
« on: November 17, 2017, 08:16:15 AM »
hello
im trying to print on one process something that its on the shared memory so when i create a player in another process i send to the "Server" a signal and it supposed to print something like -Player "name" joined...
where name is something in the shared memory
so this function its executed when server recieve the signal
Code:
//Signal sended from other process "player.c"
//function in main "server.c"
 
void signal_new_player(int mysignal){
      printf("Player: \n");
}
 
and in main:
 
signal(SIGTERM, signal_new_player);
so i was wondering if is possible to make the function something like this:

Code:
void signal_new_player(int mysignal, player *shm){
      printf("Jugador: %d joined....\n", shm[0]);
}
i mean, send more parameters (char, int, arrays, pointers, etc) to the function that is executed when the signals arrive.

thanks in advice!!



For more details :  teaser trailer