FreeBSD/usr.bin/rctl/rctl.c
/*
 * Query the kernel about a resource usage and print it out.
 */
Query the kernel about a resource usage and print it out.
Query the kernel about a resource usage and print it out .
static int
show_usage(const char *filter, const char *unexpanded_rule, int hflag)
{
	int error;
	char *copy, *outbuf = NULL, *tmp;
	size_t outbuflen = RCTL_DEFAULT_BUFSIZE / 4;
	for (;;) {
		outbuflen *= 4;
		outbuf = realloc(outbuf, outbuflen);
		if (outbuf == NULL)
			err(1, "realloc");
		error = rctl_get_racct(filter, strlen(filter) + 1,
		    outbuf, outbuflen);
		if (error == 0)
			break;
		if (errno == ERANGE)
			continue;
		if (errno == ENOSYS)
			enosys();
		warn("failed to show resource consumption for '%s'",
		    unexpanded_rule);
		free(outbuf);
		return (error);
	}
	copy = outbuf;
	while ((tmp = strsep(&copy, ",")) != NULL) {
		if (tmp[0] == '\0')
			break; 
		if (hflag)
			tmp = humanize_usage_amount(tmp);
		printf("%s\n", tmp);
	}
	free(outbuf);
	return (error);
}
static int show_usage ( const char * filter , const char * unexpanded_rule , int hflag ) { int error ; char * copy , * outbuf = NULL , * tmp ; size_t outbuflen = RCTL_DEFAULT_BUFSIZE / 4 ; for ( ; ; ) { outbuflen *= 4 ; outbuf = realloc ( outbuf , outbuflen ) ; if ( outbuf == NULL ) err ( 1 , " " ) ; error = rctl_get_racct ( filter , strlen ( filter ) + 1 , outbuf , outbuflen ) ; if ( error == 0 ) break ; if ( errno == ERANGE ) continue ; if ( errno == ENOSYS ) enosys ( ) ; warn ( " " , unexpanded_rule ) ; free ( outbuf ) ; return ( error ) ; } copy = outbuf ; while ( ( tmp = strsep ( & copy , " " ) ) != NULL ) { if ( tmp [ 0 ] == ' \0 ' ) break ; if ( hflag ) tmp = humanize_usage_amount ( tmp ) ; printf ( " \n " , tmp ) ; } free ( outbuf ) ; return ( error ) ; }
Query the kernel about a resource usage and print it out.
Query the kernel about a resource usage and print it out .
/* XXX */