change net_info to work if /etc/resolv.conf does not exist
This commit is contained in:
		
							parent
							
								
									a2572d9510
								
							
						
					
					
						commit
						e91faa5dbc
					
				@ -1220,12 +1220,9 @@ int sigar_net_info_get(sigar_t *sigar,
 | 
			
		||||
    char buffer[BUFSIZ], *ptr;
 | 
			
		||||
    FILE *fp;
 | 
			
		||||
 | 
			
		||||
    if (!(fp = fopen("/etc/resolv.conf", "r"))) {
 | 
			
		||||
        return errno;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SIGAR_ZERO(netinfo);
 | 
			
		||||
 | 
			
		||||
    if ((fp = fopen("/etc/resolv.conf", "r"))) {
 | 
			
		||||
        while ((ptr = fgets(buffer, sizeof(buffer), fp))) {
 | 
			
		||||
            int len;
 | 
			
		||||
 | 
			
		||||
@ -1249,8 +1246,8 @@ int sigar_net_info_get(sigar_t *sigar,
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        fclose(fp);
 | 
			
		||||
    } /* else /etc/resolv.conf may not exist if unplugged (MacOSX) */
 | 
			
		||||
 | 
			
		||||
    size = sizeof(netinfo->host_name)-1;
 | 
			
		||||
    if (gethostname(netinfo->host_name, size) == 0) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user