相关疑难解决方法(0)

程序收到信号SIGPIPE,Broken pipe.?

我写了一个基于posix套接字的客户端程序.该程序创建多个线程,并将锁定服务器.但是在gdb时间调试期间,程序会给出一个信息(错误)

(gdb) n
Program received signal SIGPIPE, Broken pipe. [Switching to Thread 0xb74c0b40 (LWP 4864)] 0xb7fdd424 in __kernel_vsyscall () 
(gdb) 
Run Code Online (Sandbox Code Playgroud)

这是代码:

#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>

int get_hostname_by_ip(char* h , char* ip)
{
    struct hostent *he;
    struct in_addr **addr_list;
    int i;

    if ((he = gethostbyname(h)) == NULL) 
    {
        perror("gethostbyname");
        return 1;
    }
    addr_list = (struct in_addr **) he->h_addr_list;
    for(i = 0; addr_list[i] != NULL; i++) …
Run Code Online (Sandbox Code Playgroud)

c sockets gdb pthreads sigpipe

35
推荐指数
5
解决办法
6万
查看次数

标签 统计

c ×1

gdb ×1

pthreads ×1

sigpipe ×1

sockets ×1