Thread: sending variables to a signal function

  1. #1
    Registered User
    Join Date
    Nov 2017
    Posts
    8

    Post sending variables to a signal function

    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!!
    OVNYX

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    signal(2) - Linux manual page

    Read the notes.
    1. The effects of signal() in a multithreaded process are unspecified.
    2. printf() isn't in signal-safety(7) - Linux manual page
    3. You can't invent parameters received by signals.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. signal sending and waiting
    By eva69 in forum Linux Programming
    Replies: 1
    Last Post: 10-03-2008, 05:07 PM
  2. signal sending and waiting
    By eva69 in forum C Programming
    Replies: 1
    Last Post: 10-03-2008, 12:03 PM
  3. Help with Signal Function
    By cjohnman in forum C Programming
    Replies: 2
    Last Post: 04-10-2008, 10:18 AM
  4. THe 'signal' function question
    By Nutshell in forum C Programming
    Replies: 5
    Last Post: 03-22-2002, 01:29 AM
  5. sending variables
    By canine in forum Windows Programming
    Replies: 2
    Last Post: 11-28-2001, 01:00 AM

Tags for this Thread