signal callback and pthread sync
On my app I have a pthread running a while(1) that read a socket client and a serial callback function. My app receive messages from a serial (like /dev/ttyS0) and receive messages from socket. The problem: the app crash after receive some messages from serial, on this moment the socket is receiving nothing. But if I comment the thread creation the app work fine.

code draft:

    // Socket Thread
    static void *Socket(void *arg)
    {
      // socket inicialization
      while (1)
      {
        ret = read(client, buffer, sizeof(buffer)-1);
        // do something
      }
    }
    
    // serial callback
    static void SerialCallback(int id, unsigned char *buffer, int length)
    {
        // do something
    }
    
    // main
    int main (void)
    {
      // start and configure serial callback
      cssl_start();
      Serial = cssl_open(SERIAL_PORT, SerialCallback, 0, 115200, 8, 0, 1);
    
      // create the pthread
      // If I comment the line below the app work fine
      pthread_create(&Thread_Socket, NULL, Socket, NULL);
      
      while (1)
      {
      }
    }
    


Notes:

* I use the library cssl (http://sourceforge.net/projects/cssl/) to deal with serial. This library use a real time signal.

* For tests purposes I use socat to generate pseudo-terminals (like /dev/pts/XX)

* The serial callback is called each time that serial receive one or more bytes

* I am using the cutecom to send messages to serial

signal callback and pthread sync
===

On my app I have a pthread running a while(1) that read a socket client and a serial callback function. My app receive messages from a serial (like /dev/ttyS0) and receive messages from socket. The problem: the app crash after receive some messages from serial, on this moment the socket is receiving nothing. But if I comment the thread creation the app work fine.

code draft:

    // Socket Thread
    static void *Socket(void *arg)
    {
      // socket inicialization
      while (1)
      {
        ret = read(client, buffer, sizeof(buffer)-1);
        // do something
      }
    }
    
    // serial callback
    static void SerialCallback(int id, unsigned char *buffer, int length)
    {
        // do something
    }
    
    // main
    int main (void)
    {
      // start and configure serial callback
      cssl_start();
      Serial = cssl_open(SERIAL_PORT, SerialCallback, 0, 115200, 8, 0, 1);
    
      // create the pthread
      // If I comment the line below the app work fine
      pthread_create(&Thread_Socket, NULL, Socket, NULL);
      
      while (1)
      {
      }
    }
    


Notes:

* I use the library cssl (http://sourceforge.net/projects/cssl/) to deal with serial. This library use a real time signal.

* For tests purposes I use socat to generate pseudo-terminals (like /dev/pts/XX)

* The serial callback is called each time that serial receive one or more bytes

* I am using the cutecom to send messages to serial
