一个打印UID GID PID 当前时间 当前目录的程序
时间:2006-06-06 来源:newred
#include <unistd.h>
#include <sys/types.h>
#include <time.h>
pid_t getpid(void);
pid_t getppid(void);
char *getcwd(char *buf, size_t size);
int main(void)
{
printf("process real UID: %d\n", getuid());
printf("process effect UID: %d\n", geteuid());
printf("process real GID: %d\n", getgid());
printf("process effect GID: %d\n", getegid());
printf("\n");
printf("process PID: %d\n", getpid());
printf("process PPID: %d\n", getppid());
printf("\n");
time_t now;
time(& now); /* get time */
printf("time is: %s\n", ctime(&now)); /* ctime() return char string */
printf("\n");
char buf[512];
printf("Current directory: %s\n", getcwd(buf, sizeof(buf)));
return(0);
}
#include <sys/types.h>
#include <time.h>
pid_t getpid(void);
pid_t getppid(void);
char *getcwd(char *buf, size_t size);
int main(void)
{
printf("process real UID: %d\n", getuid());
printf("process effect UID: %d\n", geteuid());
printf("process real GID: %d\n", getgid());
printf("process effect GID: %d\n", getegid());
printf("\n");
printf("process PID: %d\n", getpid());
printf("process PPID: %d\n", getppid());
printf("\n");
time_t now;
time(& now); /* get time */
printf("time is: %s\n", ctime(&now)); /* ctime() return char string */
printf("\n");
char buf[512];
printf("Current directory: %s\n", getcwd(buf, sizeof(buf)));
return(0);
}
相关阅读 更多 +