]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libc/port/getuser.c
libregexp: improve the transition to next available thread, instruction, and generation
[plan9front.git] / sys / src / libc / port / getuser.c
1 #include <u.h>
2 #include <libc.h>
3
4 char *
5 getuser(void)
6 {
7         static char user[64];
8         int fd;
9         int n;
10
11         fd = open("/dev/user", OREAD);
12         if(fd < 0)
13                 return "none";
14         n = read(fd, user, (sizeof user)-1);
15         close(fd);
16         if(n <= 0)
17                 strcpy(user, "none");
18         else
19                 user[n] = 0;
20         return user;
21 }