source:
trunk/minix/commands/simple/whoami.c@
16
| Last change on this file since 16 was 9, checked in by , 14 years ago | |
|---|---|
| File size: 351 bytes | |
| Line | |
|---|---|
| 1 | /* whoami - print the current user name Author: Terrence W. Holm */ |
| 2 | |
| 3 | #include <sys/types.h> |
| 4 | #include <pwd.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <unistd.h> |
| 7 | #include <stdio.h> |
| 8 | |
| 9 | _PROTOTYPE(int main, (void)); |
| 10 | |
| 11 | int main() |
| 12 | { |
| 13 | struct passwd *pw_entry; |
| 14 | |
| 15 | pw_entry = getpwuid(geteuid()); |
| 16 | if (pw_entry == NULL) exit(1); |
| 17 | puts(pw_entry->pw_name); |
| 18 | return(0); |
| 19 | } |
Note:
See TracBrowser
for help on using the repository browser.