Search code examples
csockets

send socket c ctrl+c behavior


I'm witting an application based on a server and various client but I'm having a problem with the send command. Whenever I do ctrl+c on the client side the send operation kills the thread which is in and the process running (in order to have multiple clients I set a thread to which one).

If the client ends (doing the close socket) properly the server doesn't die, but when I use the ctrl+c combination on the client both exit.

What can I do to prevent send command to have this behavior?

Thanks in Advance


Solution

  • Check out beej's guide to signals. You need to catch and handle the signal for CTRL+C, which is SIGINT (Terminal interrupt signal).