test4.c

来自「这个是学习嵌入式开发的重要例子」· C语言 代码 · 共 32 行

C
32
字号
#include <stdio.h>#include <sys/types.h>#include <unistd.h>#include <string.h>#include <errno.h>int main(int argc, char **argv){  fprintf(stdout, "Self process id(pid) = %d\n", getpid());  fprintf(stdout, "Parent process id(ppid) = %d\n", getppid());#if 0  // Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned and errno set to  indicate the error.  if (setuid(0) == 0)  {    fprintf(stdout, "setuid(0) successed.");  }  else  {    fprintf(stdout, "setuid(0) failed: %s\n", strerror(errno));  }#endif  fprintf(stdout, "uid = %d\n", getuid());  fprintf(stdout, "euid = %d\n", geteuid());  fprintf(stdout, "gid = %d\n", getgid());  fprintf(stdout, "egid = %d\n", getegid());  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?