[SIGAR-101] dont try using /usr/ucb/ps unless installed
This commit is contained in:
		
							parent
							
								
									57bc553dbf
								
							
						
					
					
						commit
						2423a9d47c
					
				@ -34,6 +34,7 @@
 | 
			
		||||
#include <dirent.h>
 | 
			
		||||
 | 
			
		||||
#define PROC_ERRNO ((errno == ENOENT) ? ESRCH : errno)
 | 
			
		||||
#define SIGAR_USR_UCB_PS "/usr/ucb/ps"
 | 
			
		||||
 | 
			
		||||
int sigar_os_open(sigar_t **sig)
 | 
			
		||||
{
 | 
			
		||||
@ -63,9 +64,15 @@ int sigar_os_open(sigar_t **sig)
 | 
			
		||||
    if ((ptr = getenv("SIGAR_USE_UCB_PS"))) {
 | 
			
		||||
        sigar->use_ucb_ps = strEQ(ptr, "true");
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        struct stat sb;
 | 
			
		||||
        if (stat(SIGAR_USR_UCB_PS, &sb) < 0) {
 | 
			
		||||
            sigar->use_ucb_ps = 0;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            sigar->use_ucb_ps = 1;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    sigar->pagesize = 0;
 | 
			
		||||
    i = sysconf(_SC_PAGESIZE);
 | 
			
		||||
@ -809,7 +816,7 @@ static int ucb_ps_args_get(sigar_t *sigar, sigar_pid_t pid,
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        snprintf(buffer, sizeof(buffer),
 | 
			
		||||
                 "/usr/ucb/ps -ww %ld", (long)pid);
 | 
			
		||||
                 SIGAR_USR_UCB_PS " -ww %ld", (long)pid);
 | 
			
		||||
 | 
			
		||||
        if (!(fp = popen(buffer, "r"))) {
 | 
			
		||||
            return errno;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user