shithub: riscv

ref: 65ef69a85d1c0f4694a361f5a0a99bdbb4f2cd95
dir: /sys/src/libc/9sys/getuser.c/

View raw version
#include <u.h>
#include <libc.h>

char *
getuser(void)
{
	static char user[64];
	char name[32];
	Dir *dir;

	snprint(name, sizeof(name), "/proc/%lud/status", (ulong)getpid());
	if((dir = dirstat(name)) == nil)
		return "none";
	snprint(user, sizeof(user), "%s", dir->uid);
	free(dir);
	return user;
}