diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-17 23:54:19 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-17 23:54:19 +1300 |
commit | 52306a7f6ac1dd89a0dad17024db222dd36e80a9 (patch) | |
tree | 5727030d122490ebfb5fd55b898139007266bd82 /whoami.c | |
parent | Use sizeof rather than constant (diff) | |
download | tunics-52306a7f6ac1dd89a0dad17024db222dd36e80a9.tar.gz tunics-52306a7f6ac1dd89a0dad17024db222dd36e80a9.zip |
Wrote whoami(1)
Diffstat (limited to 'whoami.c')
-rw-r--r-- | whoami.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/whoami.c b/whoami.c new file mode 100644 index 0000000..b692abe --- /dev/null +++ b/whoami.c @@ -0,0 +1,14 @@ +#include "whoami.h" + +int main(void) { + struct passwd *p; + + if ((p = getpwuid(getuid())) == NULL) { + exit(EXIT_FAILURE); + } + + printf("%s\n", p->pw_name); + + exit(EXIT_SUCCESS); +} + |