Program received signal SIGPIPE, Broken pipe

后端 未结 5 1941
陌清茗
陌清茗 2020-12-04 14:50

I write a client program based on posix sockets. The program creates multiple threads and is going to lock the server. But during debug in gdb time the program gives an info

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 15:14

    A workaround for SIGPIPE, you can ignore this signal by this code:

    #include 
    
    /* Catch Signal Handler functio */
    void signal_callback_handler(int signum){
    
            printf("Caught signal SIGPIPE %d\n",signum);
    }
    

    in your code (main or globally)

    /* Catch Signal Handler SIGPIPE */
    signal(SIGPIPE, signal_callback_handler);
    

提交回复
热议问题